Skip to content

Instantly share code, notes, and snippets.

@SquaredTiki
Created December 4, 2010 14:31
Show Gist options
  • Save SquaredTiki/728216 to your computer and use it in GitHub Desktop.
Save SquaredTiki/728216 to your computer and use it in GitHub Desktop.
NSString *myString = @"NSString Is A Test for NSRegularExpression";
NSError *error = NULL;
NSRegularExpression *regex = [NSRegularExpression
regularExpressionWithPattern:@"(NS|UI)+(\w+)"
options:NSRegularExpressionCaseInsensitive
error:&error];
[regex enumerateMatchesInString:myString options:0 range:NSMakeRange(0, [myString length]) usingBlock:^(NSTextCheckingResult *match, NSMatchingFlags flags, BOOL *stop){
NSLog(@"Text Range %@", match.range);
NSLog(@"Text %@", [myString substringWithRange:match.range]);
}];
@zzlmilk
Copy link

zzlmilk commented Aug 27, 2012

UI abhdf

@Vaseltior
Copy link

NSStringFromRange(match.range)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment