I need to split a phrase into words, digits, punctuation marks, and spaces/tabs. I also would like to preserve the order of things.
NSString *text = [NSString stringWithFormat:@"The 3 quick:\"brown fox, jump's\" over."];
This is the kind of list I need to yield:
['The', ' ', '3', ' ', 'quick, ':', '"', 'brown', ' ', 'fox', ',', ' ', 'jump's', ' ', '.']
Thank you!!
Try out this category I wrote using a
NSScanner&NSCharacterSet:Should be what you need, just change the Character Set to what you need. Also note that this was compiled with ARC enabled, so it may or may not work properly with memory management in a reference counted environment.