Title |
Test
Find
US Phone - No Toll Free or 900
|
Expression |
^\((([2-7][0-9]{2})|(8(0[^0]|[^0]0|1\d|2[^2]|[^2]2|3[^3]|[^3]3|4[^4]|[^4]4|5[^5]|[^5]5|6[^6]|[^6]6|7[^7]|[^7]7|8[^8]|[^8]8|9\d){1})|(9(0[^0]|[^0]0|[1-9][1-9])))\)\s?[0-9]{3}(-|\s)?[0-9]{4}$|^(([2-7][0-9]{2})|(8(0[^0]|[^0]0|1\d|2[^2]|[^2]2|3[^3]|[^3]3|4[^4]|[^4]4|5[^5]|[^5]5|6[^6]|[^6]6|7[^7]|[^7]7|8[^8]|[^8]8|9\d){1})|(9(0[^0]|[^0]0|[1-9][1-9])))-?[0-9]{3}-?[0-9]{4}$ |
Description |
Based on PJ Bijoy's regex for a US phone number, I've added validation that the area code is a valid US Area code (first digit is greater than 2) and that the area code is not a reserved Toll Free Code (800, 822, 833, 844, 855, 866, 877, 888) and not a premium number (900). It will accept phone patterns of ###-###-#### (3 digits dash 3 digits dash 4 digits), ########## (10 digits), (###)###-#### (3 digits in parens 3 digits dash 4 digits), (###)### #### (3 digits in parens 3 digits space 4 digits), (###) ###-#### (3 digits in parens space 3 digits dash 4 digits), (###) ### #### (3 digits in parens space 3 digits space 4 digits) |
Matches |
814-###-#### - (814) ###-#### |
Non-Matches |
800-###-#### - (866)-###-#### |
Author |
Rating:
Derrick Brown
|
Source |
PJ Bijoy |
Your Rating |
|
Title: This works great- bookmarking this!
Name: -The Dude
Date: 10/29/2014 3:34:49 PM
Comment:
Great job Derrick. This keeps all the bogus numbers out like:
1800contacts, 314dudeman, (any 9 digit number or shorter), (any 11 digit number or longer)