Skip to content

Instantly share code, notes, and snippets.

@kei-p
Last active August 29, 2015 14:16
Show Gist options
  • Save kei-p/bd52b6d9de60b60d3280 to your computer and use it in GitHub Desktop.
Save kei-p/bd52b6d9de60b60d3280 to your computer and use it in GitHub Desktop.
Objective-C regex
NSString* pattern = @"^(\\d{3})$";
NSError* error = nil;
NSRegularExpression* regex = [NSRegularExpression regularExpressionWithPattern:pattern options:NSRegularExpressionCaseInsensitive error:&error];
NSString* text = @"122";
NSArray *matches = [regex matchesInString:text options:0 range:NSMakeRange(0, text.length)];
if(matches.count>0){
NSLog(@"%@",matches);
}else{
NSLog(@"Not match!");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment