Last active
August 29, 2015 14:16
-
-
Save kei-p/bd52b6d9de60b60d3280 to your computer and use it in GitHub Desktop.
Objective-C regex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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