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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find 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
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