C# Get only number from text string

Posted by Unknown On Monday, January 19, 2015 0 comments

Problem: I want to get only number from phone number Ex. 562-810-9631 or (562) 810 9631.

Solution: Use Regular expression

C#
var phoneNumber = Regex.Replace(phoneNumber, @"\D", String.Empty, RegexOptions.Compiled);

0 comments:

Post a Comment