Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

patrover

macrumors newbie
Original poster
Aug 15, 2009
25
0
i have a string: (2434)-45455

and i want to filter out all the non-numeric chars ( i.e "()-" ), what is the best way?


thanks
 
stringByTrimmingCharactersInSet: probably won't be useful for this purpose.

Look at the string programming guide, as suggested. Also look at NSScanner. If you prefer regular expressions you could look into that as well.
 
if i'm not mistaken trimming is only for the edges of the string.
 
Can you use regex? Use that to replace all [^\d] with the empty string.

In perl it would be: s/[^\d]//g
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.