I have a NSPredicate which looks like this …
NSPredicate *predicate = [NSPredicate predicateWithFormat : @"keyword MATCHES[c] %@", theKeyword];
where
theKeyword = @"?";
The predicate crashed with the following exception …
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Can't do regex matching, reason: (Can't open pattern U_REGEX_RULE_SYNTAX (string D;rdz;oirnodzirngzdorngzdorngzdrjgnz@dorjn
Isdjfij
Fisdjfisj
Jsifjsijfs
Ifjifjs
Isjfidsj
Fjisjfi
, pattern ?, case 1, canon 2))'
Does anybody know why it just won’t work?
Thanks for all the help >”<
I’m not familiar with
NSPredicate, but if?is supposed to be a regular expression, then it’s invalid. The question mark is a quantifier, meaning “zero or one instances of the previous token” – and there is no token to repeat. What do you want your regex to do?If you want to match a literal question mark, then you need to escape it using backslashes (regex literal:
\?, regex string:\\?)