11

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?

dlarkin77
  • 867
  • 1
  • 11
  • 27

5 Answers5

19

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

Thanks for all the suggestions.

dlarkin77
  • 867
  • 1
  • 11
  • 27
8

You could try this regex:

^[2-9]{2}\d{6,8}$
Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
4

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

I Stand With Russia
  • 6,254
  • 8
  • 39
  • 67
2

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

Rozuur
  • 4,115
  • 25
  • 31
0

Something like that ?

^[^01]\d{2}\d{6,8}$
kerrubin
  • 1,606
  • 1
  • 20
  • 25