Features


Thursday, June 26, 2008

How to remove character and leave numbers in c#

Regex.Replace Method

Within a specified input string, replaces strings that match a regular expression pattern with a specified replacement string.

ex.
// assigning value into the string xvalue.
string xvalue = "199 RemoveText";

// removing character and leave numbers
decimal value = (decimal)Regex.Replace(xvalue, @"[\D]", "");

//As the result:
199