I have an NSString (phone number) with some parenthesis and hyphens as some phone numbers are formatted. How would I remove all characters except numbers from the string?
Objective-c – Remove all but numbers from NSString
nsstringobjective c
Related Topic
- Ios – How to sort an NSMutableArray with custom objects in it
- Ios – How to convert an NSString value to NSData
- Objective-c – How to convert an NSString into an NSNumber
- Ios – Convert UTF-8 encoded NSData to NSString
- Objective-c – Remove characters in NSCharacterSet from NSString
- Ios – Passing data between view controllers
- Objective-c – Remove last character of NSString
Best Answer
Old question, but how about:
It explodes the source string on the set of non-digits, then reassembles them using an empty string separator. Not as efficient as picking through characters, but much more compact in code.