C#: Remove all non numeric characters from a string using Regex
September 15, 2009
C#
Regular expressions
Snippet
using
System.Text.RegularExpressions;
...
string
newString = Regex.Replace(oldString,
"[^.0-9]"
,
""
);
(If you don't want to allow the decimal delimiter in the final result, remove the . from the regular expression above).
Related posts:
Remove extra white-spaces within a string
3 must have tools for .net developers
Remove in javascript string
Extract image tags from HTML in C#
Extend String with trim functions