Skip to content

Instantly share code, notes, and snippets.

@ctorgalson
Last active February 8, 2016 08:24
Show Gist options
  • Save ctorgalson/3763300 to your computer and use it in GitHub Desktop.
Save ctorgalson/3763300 to your computer and use it in GitHub Desktop.
North American Phone Number Regex
// This pattern matches the phone numbers ONLY (i.e. it does NOT match the
// extension or text) in:
//
// 250-370-8517 or toll free 1-888-370-8517
// 250 370 8517 or toll free 1 888 3708517
// 250 370 8517 or toll free 18883708517
// 604-851-4700 Ext. 646170
// +12503708517
// 1.250.370.8517
// (250) 370-8517
//
// It's probably possible to fool it in any case (by using weird delimiter
// characters, for example):
var pattern = /\+?(\d)?[ \.-]?(\(?\d{3}\)?)[ \.-]?(\d{3})[ \.-]?(\d{4})/g;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment