我想按组件分离字符串并将其放入数组中像
tagArray=[MyString componentsSeparatedByString:@"[Result]"];
问题是tag [Result]
内部有一些值,例如[Result 0-1]
,我如何使用通配符通过Result标签来分离组件,而不管值的变化。感谢
如果你正在使用ARC,你应该这样做:
NSError * error = nil;
__unsafe_unretained NSMutableString * authorsaddresses = [NSMutableString stringWithString:@""];
NSRegularExpression * regex = [NSRegularExpression regularExpressionWithPattern:@"^SOMEREGEX" options:NSRegularExpressionAnchorsMatchLines error:&error];
[regex enumerateMatchesInString:response options:0 range:NSMakeRange(0, [response length])
usingBlock:^(NSTextCheckingResult * result, NSMatchingFlags flags, BOOL * stop) {
[authorsaddresses appendString:response];
}];