It should be really simple, but he does not want to work. I want to get CoreData using NSPredicate, which uses NSRegularExpression. I would like to search for myString or myString_10 (10 is any possible number, for example myString_333).
This is my code:
NSString *regexString = [NSString stringWithFormat:@"%@_[0-9]+", value];
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:regexString
options:NSRegularExpressionSearch
error:&error];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(label = %@) OR (label = %@)", value, regex];
Value is a string and label is an entity key.
If the value is New Project, NSFetchRequest returns an array with one object, although I have two labels in my model (New Project and New Project_1) that need to be retrieved.
What am I doing wrong?
source
share