Created
June 26, 2014 19:13
-
Star
(202)
You must be signed in to star a gist -
Fork
(28)
You must be signed in to fork a gist
-
-
Save igorcosta/3a4caa954a99035903ab to your computer and use it in GitHub Desktop.
Regex para validar CPF e CNPJ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Para 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}$)/ |
CNPJ -> ^\d{2}.\d{3}.\d{3}-\d{4}-\d{2}$
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Mesma coisa para o aspnet core. Muito obrigado!