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 US Phone Loose
Expression
^[ 1(]{0,3}?([02-9][0-9]{2})\D{0,2}([0-9]{3})\D?([0-9]{4})($|\D+.+$)
Description
Matches US phone numbers in just about any format which doesn't try to break the 3-3-4 number set. Captures anything after the 4 digit set, such as an extension, for use later. 3 digit area code (ignoring a leading 1), 3 digit prefix, 4 digit line number and any additional extension info are all separated in to different groups for easy formatting. This expression is designed for a replacement, where the replacement string is ($1)$2-$3$4
Matches
2231231234 | 223.123.1234 | (223)123-1234 | 223#123#1234 | 1(223)123-1234 x12
Non-Matches
123123123456 | 223 112
Author Rating: Not yet rated. Sean McKibben
   Displaying page 1 of 1 pages; Items 1 to 1

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