I have this problem where I can\'t think of how to write this predicate.
I have an Entity called Contact, it has a string property \"pages\", let\'s say
The "MATCHES" operator of NSPredicate
can be used to compare against a regular expression:
NSString *pageId = @"1";
NSString *regex = [NSString stringWithFormat:@"(.*,)?%@(,.*)?", pageId];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"pages MATCHES %@", regex];
But you should also consider to replace the string property by a to-many relationship to a Page entity, then the predicate would look like
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ANY pages.pageid == %@", pageId];