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

4 comments:

Rig said...

Hi, Your posts are really useful. It would be easy for me to look for posts if you label them. Could you please label your posts.

Appreciate you work..

Leslie C. Parba said...

Thank you, for dropping some comments i really Appreciate it. thanks

Baq said...

Wow, i don't understand them posts. I'm no good at that programming stuff. But it does look lika a nice blog, and I'm sure a lot of people would fine these..uhm..codes?.. useful. :)

Leslie C. Parba said...

Hahaha. thanks leo.:)