Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regex for 8 to 10 digits [duplicate]

Tags:

c#

regex

I'm looking for a simple regex exp that will validate a phone number. The number can be between 8 an 10 digits and there can be no other characters. Can someone help out?

like image 218
dlarkin77 Avatar asked Jan 12 '11 09:01

dlarkin77


4 Answers

It looks like ^[0-9]{8,10}$ does the trick.

Thanks for all the suggestions.

like image 88
dlarkin77 Avatar answered Oct 21 '22 06:10

dlarkin77


You could try this regex:

^[2-9]{2}\d{6,8}$
like image 29
Darin Dimitrov Avatar answered Oct 21 '22 04:10

Darin Dimitrov


\d{8,10}: would be the simplest way

like image 3
LastTribunal Avatar answered Oct 21 '22 05:10

LastTribunal


Haven't checked it but i guess this will work [2-9][0-9]{7,9}

like image 2
Rozuur Avatar answered Oct 21 '22 04:10

Rozuur