Derin
Derin

Reputation: 2185

C# Regex to validate phone number

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

Here are some valid numbers:

Thanks in advance

Upvotes: 16

Views: 41063

Answers (2)

Dmitry
Dmitry

Reputation: 17350

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.

Upvotes: 4

hsz
hsz

Reputation: 152284

Try with:

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

However it does not handle number counting

Upvotes: 26

Related Questions