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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
^([\(]{1}[0-9]{3}[\)]{1}[\.| |\-]{0,1}|^[0-9]{3}[\.|\-| ]?)?[0-9]{3}(\.|\-| )?[0-9]{4}$
Description
More permissive than others on the site, this one allows you to let a user enter US phone numbers in the way they most commonly use, without letting them enter non-valid combinations.
Matches
5551212 | 614555-1212 | (614)555-1212
Non-Matches
A12-5555 | (614-555-1212 | 555*1212
Author Rating: The rating for this expression. Jeff Gabriel
Source a modification of one submitted by 'gabe g'
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: Incorrect syntax.
Name: g1smd
Date: 8/5/2012 1:01:58 PM
Comment:
The [\(]{1} simplifies to \( here. The [\)]{1} simplifies to \) here. When there's only one character, there's no need to use character group syntax. Additionally, the {1} is completely redundant. The [\.| |\-]{0,1} simplifies to [\s.-]? here. The [\.|\-| ]? simplifies to [\s.-]? here. Using pipes within a character group is completely incorrect.


Title: add in other commons
Name: Mike
Date: 10/9/2003 2:57:18 PM
Comment:
You could also add in other commons such as: 000-000-0000


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