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}[ ]{1}[0-9]{3}[\-]{1}[0-9]{4})$
Description
It is the exact phone number regular expression for '(###) ###-####'. Written by Jason Gaylord.
Matches
(555) 555-1212
Non-Matches
555-1212 | 1-800-555-1212 | 555-555-1212
Author Rating: The rating for this expression. Jason N. Gaylord
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: Incorrect syntax.
Name: g1smd
Date: 8/5/2012 2:57:56 AM
Comment:
The [\(]{1} simplifies to \( here. The [\)]{1} simplifies to \) here. The [ ]{1} simplifies to \s here. The [\-]{1} simplifies to - here. When there is only one character there is no need to use 'character group' syntax. In any case, stating {1} is aways redundant too.


Title: Incorrect syntax.
Name: g1smd
Date: 8/5/2012 2:54:41 AM
Comment:
The [\\(]{1} simplifies to \\( here. The [\\)]{1} simplifies to \\) here. The [ ]{1} simplifies to \\s here. The [\\-]{1} simplifies to \\- here. When there is only one character there is no need to use 'character group' syntax. In any case, stating {1} is aways redundant too.


Title: Invalid Phone Numbers
Name: Mihalko
Date: 6/28/2011 1:09:20 PM
Comment:
It allows for some invalid phone number where the area code and local code start with 0. ex: (011) 012-1234 ^([\(]{1}[2-9]{1}[0-9]{2}[\)]{1}[ ]{1}[2-9]{1}[0-9]{2}[\-]{1}[0-9]{4})$ <----http://www.area-codes.com/area-code-faq.asp----> “NPA” stands for Number Plan Area, commonly called Area Code. “NXX” refers to the three digits of a phone number immediately following the area code, also called the “exchange” or the “Central Switching Office Designation. In the number (555) 222-3333, the NPA is “555” and the NXX is “222”. The “N” numbers, or the first number of the NPA and of the NXX, can be any number from 2-9; 0 and 1 are reserved for special purposes. All the remaining numbers, or “X” numbers, can be any number from 0-9. The last four digits of a phone number are called the “Subscriber Line Identifier,” or “SLID”, and can be any number from 0-9..


Title: Perfect
Name: Chuck Bittner
Date: 1/21/2007 2:14:32 PM
Comment:
This is exactly what I needed to force a US (###) ###-#### format, works great - thanks.


Title: electrician
Name: jesse andrade
Date: 9/16/2005 6:53:46 PM
Comment:
want to learn


Title: programmer
Name: Denis
Date: 11/15/2004 11:36:11 AM
Comment:
exactly what I need. good one, even if has extra brakets, it does the trick.


Title: why extras?
Name: Jakub Skopal
Date: 9/20/2003 5:11:12 AM
Comment:
the extra brackets and quantifiers are completelly unnecessary... @"^\(\d{3}\) \d{3}-\d{4}$" is just as good only more 'readable' :-)


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