Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // myList is a NSMutableArray formed when the program starts
- NSError *error;
- NSString *string = @"This is my long long string";
- NSString *pattern;
- for (NSString * word in myList){
- pattern = [NSString stringWithFormat: @"\b%@\b", word];
- NSRegularExpression *regex = [NSRegularExpression
- regularExpressionWithPattern:pattern
- options:NSRegularExpressionCaseInsensitive error:&error];
- [regex enumerateMatchesInString:string options:0
- range:NSMakeRange(0, [string length])
- usingBlock:^(NSTextCheckingResult *match,
- NSMatchingFlags flags, BOOL *stop){
- ... doing smthg with matched word location
- }];
- }
Add Comment
Please, Sign In to add comment