既然苹果现在似乎拒绝了链接到libicucore的应用程序(例如利用RegexKitLite的应用程序),那么在iPhone应用程序中使用具有捕获组功能的正则表达式的最佳方法是什么?应该静态编译ICU还是PCRE (也许使用RegexKit PCRE包装器)?
发布于 2010-06-30 13:55:26
有关使用RegexKitLite的应用程序被拒绝的原因的详细信息,请参阅this cocoa-dev post。
简短的答案是仍然可以使用RegexKitLite和,而不是 get rejected。
发布于 2011-03-06 05:48:57
我正在通过NSRegularExpression获得第一个组,用第一个组替换命中:
string="abcde“pattern=”b(C)。“=> hit="bcd”=> group="c“
NSRegularExpression* regex=[NSRegularExpression regularExpressionWithPattern:pattern options:0 error:nil];
NSRange range=[regex rangeOfFirstMatchInString:self options:0 range:NSMakeRange(0, [self length])];
String hit=[self substringWithRange:range];
return [regex stringByReplacingMatchesInString:hit options:0 range:NSMakeRange(0, [hit length]) withTemplate:@"$1"];https://stackoverflow.com/questions/3125324
复制相似问题