How to validate a (country specific) phone number

前端 未结 8 630
一个人的身影
一个人的身影 2020-12-30 00:44

A valid phone number contains:

  • Less than 9 characters
  • A "+" at the start
  • Only digits.

I\'m trying to use regular expre

8条回答
  •  礼貌的吻别
    2020-12-30 00:48

    Something like this could work:

    ^+\d{0,9}

    But I would suggest playing around with a regex tester to learn more about how regular expressions work. I still like to use them heavily myself, as I don't write regular expressions often. Here is one example but there are many more out there.

    https://regex101.com/

提交回复
热议问题