我在使用简单的 NSPredicates 和正则表达式时遇到问题:
NSString *mystring = @"file://questions/123456789/desc-text-here";
NSString *regex = @"file://questions+";
NSPredicate *regextest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
BOOL isMatch = [regextest evaluateWithObject:mystring];
在上面的例子isMatch
中总是假/否。
我错过了什么?我似乎找不到匹配的正则表达式file://questions
。