I'm implementing a validator function in a form that has this regex /^[\d\s ().-]+$/ for phone numbers.
I would like to change it to accept a starting + and then all combinations of [0-9] . - , ( ).
I'm implementing a validator function in a form that has this regex /^[\d\s ().-]+$/ for phone numbers.
I would like to change it to accept a starting + and then all combinations of [0-9] . - , ( ).
 
    
     
    
    since you want to start with +, you need to tell the engine to start with + by escaping it since it has another meaning,
/^\+[\d\s ().-]+$/
the answer simply answers what you ask but the it does not give you proper result since it will match with +...,..(), I can modify this if you can specifically tell us the acceptable patter you want, eg +639151234567
 
    
    That's pretty easy. Don't forget to escape the "+". I assume the "+" is optional, thus use the ? quantifier.
/^\+?[0-9(),.-]+$/
 
    
    Below regex can match any type of number, remember, I have assumed + to be optional.
However it does not handle number counting
^\+?(\d[\d-. ]+)?(\([\d-. ]+\))?[\d-. ]+\d$
Here are some valid numbers you can match:
+91293227214
+3 313 205 55100
99565433
011 (103) 132-5221
+1203.458.9102
+134-56287959
(211)123-4567
111-123-4567
 
    
    Well, this is the best I can come up with. I merged many of the regex given in other answers.
/^[+]?(1\-|1\s|1|\d{3}\-|\d{3}\s|\d{2}\-|\d{2}\s|)?((\(\d{3}\))|\d{3})(\-|\s)?(\d{3}) 
(\-|\s)?(\d{4})$/g
This should support all combinations like
and so on.
