WhatsApp Phone number Regex [duplicate]

牧云@^-^@ 提交于 2020-12-15 05:25:34

问题


I'm trying to make this Regex allow this symbol -

For Example this Phone Number is not matching right now +212 659-639217

So I need some one to help me change the Regex to allow it please Here is the Regex:

^\+(?:[0-9]\x20?){6,14}[0-9]$


回答1:


How about this one?

([+]*\d{3,})*\s?\d{3}[-]?\d{6}

  • Optional plus sign
  • Optional space (between country code and the rest)
  • Optional dash

Update

\+\d{3}[ ]?(\d+(-| )?)+

  1. Expect plus sign.
  2. Expect 3 digit number (country code).
  3. Optional whitespace.
  4. Any number of digits followed by an optional dash OR a whitespace
  5. Repeat the previous step for 1 or more times.


来源:https://stackoverflow.com/questions/65076894/whatsapp-phone-number-regex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!