Regular Expressions for U.S. Phone Numbers


/ Published in: Regular Expression
Save to your folder(s)

(Created for JavaScript)

These are rather forgiving. Spaces, dashes, or periods are allowed as separators. Extensions can be recognized by several strings (#, x, x., ext, ext., extension).

Area code: $1$2
Exchange code: $3
Station code: $4
Extension / Extra characters: $5

Separators are not accepted within the $3$4$5 portion of a vanity number.

Example: (540) 555-0123 ext.678 --> `($1$2) $3-$4 ext.$5`
Example: 1-800-GOODFOOD --> `1-$1$2-$3$4$5`

URL: http://en.wikipedia.org/wiki/North_American_Numbering_Plan

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.