Skip to content

Instantly share code, notes, and snippets.

@guilhermewebdev
Last active February 1, 2020 19:33
Show Gist options
  • Save guilhermewebdev/5da7869710866d01b5be4fd7243d5693 to your computer and use it in GitHub Desktop.
Save guilhermewebdev/5da7869710866d01b5be4fd7243d5693 to your computer and use it in GitHub Desktop.
Expressão regular de telefone brasileiro para JavaScript
/((\([0-9]{2}\))|([0-9]{2}))( ?9)? ?([0-9]{4})(-| )?([0-9]{4})/igm
/*
O padrão aceita várias mascaras diferentes para o telefone, com ou sem o 9º digito.
Alguns exemplos são:
(##) 9 ####-####
(##) ####-####
Com ou sem os parêntesis:
## ####-####
######-####
Com ou sem o traço:
## #### ####
## ########
## ####-####
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment