1

我正在尝试将 NSString 分离到 NSArray 中。我总是使用“componentsSeparatedByString”来分隔 NSString。但是这种方法只能得到单个分隔符,也没有任何条件。我想将字符串与“点+空格”、“点+换行”、“点+空”、“!”分开 和 ”?”。我确信这可以用正则表达式完成,但不知道如何:D。我以前从未使用过正则表达式。

谢谢

4

1 回答 1

0

You can try the following hope it will work for you

NSString *strTest = @"a.b+c";

NSLog(@"seperated  %@", [strTest componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@".+"]]);
于 2012-12-20T09:30:24.740 回答