C# Regex to validate phone number

前端 未结 2 2017
感动是毒
感动是毒 2021-01-01 18:26

It would be great if someone could help me with a Regex for phone numbers. Following are the conditions:

  • If + is present, then it should be the first character
相关标签:
2条回答
  • 2021-01-01 18:54

    Not exactly the answer to your question, but for those who need to work with phone numbers, there is a .NET port of Google's libphonenumber: libphonenumber-csharp.

    0 讨论(0)
  • 2021-01-01 19:09

    Try with:

    ^\+?(\d[\d-. ]+)?(\([\d-. ]+\))?[\d-. ]+\d$
    

    However it does not handle number counting

    0 讨论(0)
提交回复
热议问题