Phone validation regex

后端 未结 16 1527
孤城傲影
孤城傲影 2020-11-27 02:56

I\'m using this pattern to check the validation of a phone number

^[0-9\\-\\+]{9,15}$

It\'s works for 0771234567 and +0

16条回答
  •  温柔的废话
    2020-11-27 03:43

    Here is the regex for Ethiopian Phone Number. For my fellow Ethiopian developers ;)

    phoneExp = /^(^\+251|^251|^0)?9\d{8}$/;
    

    It matches the following (restrict any unwanted character in start and end position)

    • +251912345678
    • 251912345678
    • 0912345678
    • 912345678

    You can test it on this site regexr.

提交回复
热议问题