Published
- 1 min read
regex cpf
The solution for this is noted below
regex cpf
Solution
// CPF
/^\d{3}\.\d{3}\.\d{3}-\d{2}$/
// Para CNPJ
/^\d{2}\.\d{3}\.\d{3}\/\d{4}\-\d{2}$/
// Para ambos ao mesmo tempo
/(^\d{3}\.\d{3}\.\d{3}\-\d{2}$)|(^\d{2}\.\d{3}\.\d{3}\/\d{4}\-\d{2}$)/
Try other methods by searching on the site. That is if this doesn’t work