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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find U.S. Phone numbers
Expression
^(((\(\d{3}\)|\d{3})( |-|\.))|(\(\d{3}\)|\d{3}))?\d{3}( |-|\.)?\d{4}(( |-|\.)?([Ee]xt|[Xx])[.]?( |-|\.)?\d{4})?$
Description
with or without area code (of various forms)(does not allow for unbalanced parens in the area code). With or without an extension (of various forms). Does not allow for leading or trailing space.
Matches
(123)-456-7890 Ext 1234 | 123-456-7890 | (123).456.7890 | 123.456.7890 | 1234567890ext1234 | 123-456 7890 X 1234
Non-Matches
123)4567890 | 800callcat | 123456789
Author Rating: Not yet rated. Rick LaCount
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

Title: Works good but..
Name: Tester
Date: 3/30/2007 10:15:35 AM
Comment:
Why does the extension, if you use one, have to be 4 digits?? Why not between 2 and 4 digits or something. I would really like to use it but the extension must be more flexible.


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