Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
102
rated 0 times [  108] [ 6]  / answers: 1 / hits: 47290  / 11 Years ago, wed, april 10, 2013, 12:00:00

Greetings overflowers,



I'm trying to write a regular expression to validate phone numbers of the form ########## (10 digits)
i.e. this is these are cases that would be valid: 1231231234 or 1111111111. Invalid cases would be strings of digits that are less than 10 digits or more than 10 digits.



The expression that I have so far is this:
d{10}



Unfortunately, it does not properly validate if the string is 11+ digits long.



Does anyone know of an expression to achieve this task?


More From » regex

 Answers
19

You need to use ancors, i.e.



/^d{10}$/

[#78979] Wednesday, April 10, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jaden

Total Points: 709
Total Questions: 91
Total Answers: 91

Location: Maldives
Member since Sat, Jan 29, 2022
2 Years ago
;