0

I was looking for a regex that can validate phone numbers, but somehow i cannot find a universal solution.

So i just want to check if the string has any alphabets that is a-z

If it does not then pass it, for example

000 -> Pass

000(1) -> Pass

000a -> Fail

Pradyut Bhattacharya
  • 5,440
  • 13
  • 53
  • 83

2 Answers2

2

(?mx)^(?=.*?([0-9]))((?![a-zA-Z]).)*$

This will check to see if your line has any numbers in it while NOT having any alpha chars. See the example here.

Walls
  • 3,972
  • 6
  • 37
  • 52
0

its for phone numbers validation

RegExp(/^[0-9 +()-]{3,30}$/i)

for only string

RegExp(/^[a-zA-Z]{1,2}$/i)
Bhaskar Bhatt
  • 1,399
  • 13
  • 19