Skip to content

Instantly share code, notes, and snippets.

@dgmike
Created February 15, 2013 18:56
Show Gist options
  • Save dgmike/4962499 to your computer and use it in GitHub Desktop.
Save dgmike/4962499 to your computer and use it in GitHub Desktop.
Regular expression to test phone numbers in Brazil, including the new Sao Paulo cel phones - that needs to have 9 in first non DDD number.
regexTel = /^\(11\) 9\d{4}-\d{4}|\((?:1[2-9]|[2-9]\d)\) [5-9]\d{3}-\d{4}$/
"(11) 93827-5555".match(regexTel) // OK
"(12) 8201-5555".match(regexTel) // OK
"(11) 89201-5555".match(regexTel) // NOT OK
"(12) 99201-5555".match(regexTel) // NOT OK
"(11) 4201-5555".match(regexTel) // NOT OK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment