Skip to content

Instantly share code, notes, and snippets.

@patrickkettner
Created January 31, 2012 22:40
Show Gist options
  • Save patrickkettner/1713531 to your computer and use it in GitHub Desktop.
Save patrickkettner/1713531 to your computer and use it in GitHub Desktop.
allows for optional parens, dashes, dots, and country code
^(?:(?:\+?1\s*(?:[.-]\s*)?)?(\()?(?:(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])(\))?\s*)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment