Regex of Phone number?

-1
could you please provide the regex  of  phone numbers . ex: 9542569841 8340860380 7756894581 6458745554.
asked
2 answers
1

You could take a look at the Phone Number Validator module in the Market Place.

If you want a regex for 10 digits not starting with zero you could try something like:

[1-9][0-9]{9}

 

answered
0

The following regex would do the trick:

/^\d{10}$/


Explanation of the regex:

  • ^ matches the start of the string
  • \d matches any digit (0-9)
  • {10} specifies that there should be exactly 10 digits
  • $ matches the end of the string

 

Note that this regex assumes that the phone numbers are in the correct format and do not contain any spaces, dashes, or parentheses. If the phone numbers are in a different format, the regex would need to be adjusted accordingly.

answered