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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Versitile North American Phone Number Validation
Expression
[\+]?[\s]?(\d(\-|\s)?)?(\(\d{3}\)\s?|\d{3}\-?)\d{3}(-|\s-\s)?\d{4}(\s(ex|ext)\s?\d+)?
Description
My goal with this was to have a pretty loose and flexible validation, accept a number of different input strings, but still inforce the core of what a phone number is. Country Code optional, Area Code required, with optional extension as well for business numbers. I'm still fairly new to Regex's so any suggestions for improvement are great.
Matches
+12345678910 | +1 (234)567-8910 | (234)567-8910 | 2345678910 | 234-567-8910 | 1-888-666-1111 ext 123 | 1-999-555-3333 ex 123
Non-Matches
1234567891011 | 555-(123)-4567 | 123-4567
Author Rating: Not yet rated. Mitchell Lee
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