P patrover macrumors newbie Original poster Aug 15, 2009 25 0 Sep 7, 2009 #1 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
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
dejo Moderator emeritus Sep 2, 2004 15,982 452 The Centennial State Sep 7, 2009 #2 Have you looked through the NSString Class Reference or the String Programming Guide for Cocoa?
MacDonaldsd macrumors 65816 Sep 8, 2005 1,005 0 London , UK Sep 7, 2009 #3 dejo said: Have you looked through the NSString Class Reference or the String Programming Guide for Cocoa? Click to expand... Thats obviously the best place to start. If you read through them you will find. Code: - (NSString *)stringByTrimmingCharactersInSet:(NSCharacterSet *)set;
dejo said: Have you looked through the NSString Class Reference or the String Programming Guide for Cocoa? Click to expand... Thats obviously the best place to start. If you read through them you will find. Code: - (NSString *)stringByTrimmingCharactersInSet:(NSCharacterSet *)set;
PhoneyDeveloper macrumors 68040 Sep 2, 2008 3,114 93 Sep 7, 2009 #4 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.
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.
dejo Moderator emeritus Sep 2, 2004 15,982 452 The Centennial State Sep 7, 2009 #5 PhoneyDeveloper said: stringByTrimmingCharactersInSet: probably won't be useful for this purpose. Click to expand... Just curious: why do you say this?
PhoneyDeveloper said: stringByTrimmingCharactersInSet: probably won't be useful for this purpose. Click to expand... Just curious: why do you say this?
P patrover macrumors newbie Original poster Aug 15, 2009 25 0 Sep 8, 2009 #6 if i'm not mistaken trimming is only for the edges of the string.
dejo Moderator emeritus Sep 2, 2004 15,982 452 The Centennial State Sep 8, 2009 #7 patrover said: if i'm not mistaken trimming is only for the edges of the string. Click to expand... Ah, that's right. Perhaps one of the stringByReplacing... methods will suit your needs.
patrover said: if i'm not mistaken trimming is only for the edges of the string. Click to expand... Ah, that's right. Perhaps one of the stringByReplacing... methods will suit your needs.
R RaceTripper macrumors 68030 May 29, 2007 2,894 197 Sep 8, 2009 #8 Can you use regex? Use that to replace all [^\d] with the empty string. In perl it would be: s/[^\d]//g
Can you use regex? Use that to replace all [^\d] with the empty string. In perl it would be: s/[^\d]//g