Guest User

Untitled

a guest
Dec 10th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. // myList is a NSMutableArray formed when the program starts
  2.  
  3. NSError *error;
  4. NSString *string = @"This is my long long string";
  5. NSString *pattern;
  6.  
  7. for (NSString * word in myList){
  8. pattern = [NSString stringWithFormat: @"\b%@\b", word];
  9. NSRegularExpression *regex = [NSRegularExpression
  10. regularExpressionWithPattern:pattern
  11. options:NSRegularExpressionCaseInsensitive error:&error];
  12. [regex enumerateMatchesInString:string options:0
  13. range:NSMakeRange(0, [string length])
  14. usingBlock:^(NSTextCheckingResult *match,
  15. NSMatchingFlags flags, BOOL *stop){
  16.  
  17. ... doing smthg with matched word location
  18. }];
  19.  
  20. }
Add Comment
Please, Sign In to add comment