For text bozo__foo!!bar.baz
, how to split an NSString containing this into (bozo, foo, bar, baz)
?
That is, separe it in components with strings (delimiters) __
, !!
and .
.
You can split the strings using NSCharacterSet. Try this
NSString *test=@"bozo__foo!!bar.baz";
NSString *sep = @"_!.";
NSCharacterSet *set = [NSCharacterSet characterSetWithCharactersInString:sep];
NSArray *temp=[test componentsSeparatedByCharactersInSet:set];
NSLog(@"temp=%@",temp);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With