RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Parse North American Phone Numbers
Expression
^(?<CountryCode>[1]?)\s?\(?(?<AreaCode>[2-9]{1}\d{2})\)?\s?(?<Prefix>[0-9]{3})(?:[-]|\s)?(?<Postfix>\d{4})\s?(?:ext|x\s?)(?<Extension>[1-9]{1}\d*)?$
Description
Validates any format of North American phone number, while parsing the Country Code, Area (City) Code, Prefix and Postfix numbers and the letters ext or x followed by the extension number which cannot begin with 0. Will not accept invalid Area Codes
Matches
1234567890 | 1(234)4567890 | (234) 456-7890 ext 2
Non-Matches
(000) 234 5678 | 100 234 5678 | aaa bbb cccc | 1 234 567 8990 ext 01 | 234-5678
Author Rating: Not yet rated. Allen Mayes
Source
Your Rating
Bad Good

Enter New Comment

Title

Name

Comment

Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Copyright © 2001-2025, RegexAdvice.com | ASP.NET Tutorials