I’ m searching function that will works like preg_match_all (or similar) from for example PHP.
I want give a pattern and my NSData object(with HTML content) then get all results that fits to pattern.
I’ m programming iOS 5. Is there any library or function to do this ?
Take a look at the NSRegularExpression class.
Here’s a snippet of code that uses it:
NSError *error = nil; NSRegularExpression *tagsRegex = [NSRegularExpression regularExpressionWithPattern:@"(<b>|<u>|<i>|<br/?>)" options:NSRegularExpressionCaseInsensitive error:&error]; if (!tagsRegex) { NSLog(@"Tags regex creation error: %@", [error localizedDescription]); } if ([tagsRegex numberOfMatchesInString:marketingMessage options:0 range:NSMakeRange(0, [marketingMessage length])]) { ... }