Skip to content

Instantly share code, notes, and snippets.

@PyramisDev
Created October 3, 2013 12:47
Show Gist options
  • Save PyramisDev/6809274 to your computer and use it in GitHub Desktop.
Save PyramisDev/6809274 to your computer and use it in GitHub Desktop.
The following regex attempts to match numbers that adhere to the North American Numbering Plan. It matches common entry combinations, such as #######, ###.###.####, ###-###-####, ### ### ####, and (###) ### ####. http://www.gigoblog.com/2008/11/28/regex-preg_match-for-zip-codes-phone-numbers-states-urls-and-email-addresses/
/\(?[2-9][0-8][0-9]\)?[-. ]?[0-9]{3}[-. ]?[0-9]{4}/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment