-2

I am validating international phone number which may have + or 0 leading with country code and space and phone number after space for this tried reglar expression with '\s' but it is failing.Why it is failing? For eg. +65 3333311

Tried with below regular expression ^([0|\+[0-9]{1,6}[\s]?)?([0-9]{8,10})$

  • The first `[` is a typo (must be removed) and note that `3333311` is made of 7 digits while `{8,10}` expects at least 8. Also, bear in mind that `[\s]` should be written as `\s`. See [this demo](https://regex101.com/r/vB8vlv/1). – Wiktor Stribiżew Jan 22 '19 at 11:05
  • You should add specific error/expected value for us to see what went wrong with your attempt. – YetAnotherBot Jan 22 '19 at 11:48

1 Answers1

0
^[+0](?:\d\s?){8,12}$

Leading + or 0 followed by 8 to 12 digits with optional separator after every digit.

bw_üezi
  • 4,483
  • 4
  • 23
  • 41