Sheehan Alam
Sheehan Alam

Reputation: 60869

Can I separate an NSString by more than 1 separator?

I would like to separate my string by spaces, commas, periods (ie. punctuations). I am using:

[myString componentsSeparatedByString:@" "];

to separate by spaces, but need to be able to split by punctuations as well.

Upvotes: 2

Views: 3090

Answers (1)

Chuck
Chuck

Reputation: 237010

Use componentsSeparatedByCharactersInSet: with a character set made up of whatever characters you want to split by.

Upvotes: 5

Related Questions