Thursday, 19 September 2013

Regex pattern for Validating phone number in C#

Regex pattern for Validating phone number in C#

I have a input string ("My phone number is 860-678 - 2345"). From the
input string I need to validate phone number using Regex and need to
replace the phone number with (xxxxxxxxxx).
I am using the below pattern but it doesn't work if the phone number
contains white Space in it.
[(]?[2-9]{1}[0-9]{2}[)-. ,]?[2-9]{1}[0-9]{2}[-. ,]?[0-9]{4}
Thanks.

No comments:

Post a Comment