I wrote simple method for checking if given array has at least one string, that matches provided pattern... but something is missing and not sure how to limit positive results only to full words, not just first substring that fits pattern.
+ (BOOL)hasWordsWithPattern:(NSString *)pattern inWords:(NSArray *)words{
NSRegularExpression *expression = [NSRegularExpression regularExpressionWithPattern:pattern
options:NSRegularExpressionCaseInsensitive
error:nil];
for (NSString *s in words) {
if ([expression matchesInString:s
options:0
range:NSMakeRange(0, s.length)]) {
NSLog(@"there is a match!");
return YES;
}
}
NSLog(@"sorry, no match found!");
return NO;
}