Matoe Matoe - 1 year ago 163
Objective-C Question

Split NSString with multiple delimiters?

For text

, how to split an NSString containing this into
(bozo, foo, bar, baz)

That is, separe it in components with strings (delimiters)

Answer Source

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];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download