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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find US Phone
Expression
^(1|1(\s|\s?-\s?|\s?\.\s?|\s?/\s?))?((\(?[2-9]{1}[\d]{2}\)?(\s|\s?-\s?|\s?\.\s?|\s?/\s?)?))?(\d{3})(\s|\s?-\s?|\s?\.\s?|\s?/\s?)?(\d{4})$
Description
USA Phone number with dash, periods, slashes, spaces, () and only last 7 digit is required but everything else is checked Here it is broken down feel free to add too it or use it Begin String: ^ Country Code 1: (1|1(\s|\s?-\s?|\s?\.\s?|\s?/\s?))? Area Code FirstDigit cannot be 0 or 1:((\(?[2-9]{1}[\d]{2}\)?(\s|\s?-\s?|\s?\.\s?|\s?/\s?)?))? 3Digit Prefix: (\d{3}) Space/-/. between: (\s|\s?-\s?|\s?\.\s?|\s?/\s?)? 4Digit Suffix: (\d{4}) End String $ *can add country code with out area code!!
Matches
555-5555 1-555-555-5555 1-(555)-555-5555
Non-Matches
0 or 1 starts area code, 1 isn't the country code, non-valid US numbers
Author Rating: The rating for this expression. Philip
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-2024, RegexAdvice.com | ASP.NET Tutorials