Skip to content

Instantly share code, notes, and snippets.

@aradnom
Created March 24, 2017 21:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aradnom/2fafed06d37c7dab7256e1d9b87d662b to your computer and use it in GitHub Desktop.
Save aradnom/2fafed06d37c7dab7256e1d9b87d662b to your computer and use it in GitHub Desktop.
Parse a phone number with regex. May take some finessing with a few formats, but will attempt to parse country code, area code and number.
/(\d{1,3})?(\s|-|\.)?\(?(\d{3})?\)?(\s|-|\.)?(\d{3})(\s|-|\.)?(\d{4})/.exec( string );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment