Removing Non-Numeric Characters from a string (The easy way)

Thursday, 17 November 2011 10:38 animaonline
I was searching the web for a way to easily remove all non numeric characters from a string, but the only thing I found was some "for loop" code, which really slowed down my application, so after a little research I came up with a simple way to do it using Regular Expressions

Here it goes:

string Temp = "Hax00r L33t";
string Output = Regex.Replace(Temp, "[^0-9]", "");

Comments (0)Add Comment

Write comment
smaller | bigger

busy

Latest tweets

about 6 hours ago Was out walking 2.96 km with #Endomondo . See it here: http://t.co/c9k3s4mV
about 5 days ago @Lordovos yeah, it's a great game. What do you think about #dqix ?
about 5 days ago #dqviii time http://t.co/fH8wUtQV
about 5 days ago My Top 3 #lastfm Artists: Eminem (52), Dieselboy (32) & Disturbed (11) http://t.co/YPJlaiyy
about 6 days ago Was out walking 1.83 km with #Endomondo . See it here: http://t.co/rLVd9mFS
about 6 days ago Was out walking 0.00 km with #Endomondo . See it here: http://t.co/E7m2A2aQ
about 6 days ago Can't believe so few have heard of #OSI , check them out on @Spotify They are awesome! http://t.co/mayiR94r #progressiverock
about 7 days ago Playing #DragonQuestVIII #dqviii
about 9 days ago Was out walking 2.64 km with #Endomondo . See it here: http://t.co/qpusEsHW
about 9 days ago Off to #work #tgif :-D
about 10 days ago ♥ Hellbound by Eminem #lastfm : http://t.co/7uxCWRlu
about 11 days ago Was out walking 1.60 km with #Endomondo . See it here: http://t.co/u3ZlyiRB
about 11 days ago #Stackoverflow is kinda fun, I like!! #dev
about 12 days ago @YngveNilsen really? Congrats!! :-D

Tag Cloud