0

I got this regular expression for validating phone number

/^(\+)?[\d\s\-\(\)]+$/

This validates most of the phone numbers except -

+01 (555 236 4960

here the closing brace is missing but it does not validate this. What should be changed in the existing regex so that it matches the closing brace as well

Avinash Raj
  • 172,303
  • 28
  • 230
  • 274
user2053459
  • 135
  • 2
  • 7
  • Did you google for it, you will get answer (Similar questions has been asked multiple times on this forum)? – SMA Jun 19 '15 at 09:27
  • it works https://regex101.com/r/xD4nB1/1 – Avinash Raj Jun 19 '15 at 09:28
  • That regex will also match `-`. [Example](http://regexr.com/3b83r) – Sayse Jun 19 '15 at 09:29
  • +01 (555 236 4960 should not be matched with the above regex as the closing parenthesis is missing. So ideally i want a regex with must throw an error if the closing parenthesis is missing. – user2053459 Jun 19 '15 at 11:12

0 Answers0