ios - Removing all numbers from a string -


i have string need remove numerical values from. example

h1 --> h thi2341s i34s a876 57834tes9873t --> test 

and forth...

i tried method...

nsstring *newstring = [string stringbyreplacingoccurrencesofstring:@"[^0-9]" withstring:@""]; 

... though didn't remove numbers string. guessing @"[^0-9]" isn't valid occurrence. ideas of how can achieve without copying method ten times each digit?

you have indicate regular expression search should used:

nsstring *newstring = [string stringbyreplacingoccurrencesofstring:@"[0-9]" withstring:@"" options:nsregularexpressionsearch range:nsmakerange(0, string.length)]; 

and note regular expression needs [0-9], not [^0-9]. have says "any character except digits 0-9".


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -