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

Please support RegExLib Sponsors

Sponsors

Expressions by User

   Displaying page 1 of 1 pages; Items 1 to 1
Title Test Details 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
   Displaying page 1 of 1 pages; Items 1 to 1

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