C # Regex for checking phone number

It would be great if someone would help me with Regex for phone numbers. The following are the conditions:

  • If + is present, then this must be the first character
  • Allowed characters are numbers () - and.
  • Minimum 6 rooms and max. 12
  • (,) and a space may be on the line
  • - should not be the first and last character and should not appear immediately after + if + is present.

Here are some valid numbers:

  • +93483227359
  • +1 703 335 65123
  • 34565464
  • 001 (703) 332-6261
  • +1703.338.6512
  • + 934-83227359
  • (111) 123-4567
  • 111-123-4567

Thanks in advance

+14
c # regex
source share
2 answers

Try:

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

However, it does not handle counting a number

+21
source share

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

+3
source share

All Articles