Created
March 8, 2013 12:38
-
-
Save joanromano/5116211 to your computer and use it in GitHub Desktop.
Returns the NSRange of a given regular expression pattern
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
- (NSRange)rangeOfRegularExpressionPattern:(NSString *)pattern inString:(NSString *)string | |
{ | |
NSRegularExpression *expression = [NSRegularExpression regularExpressionWithPattern:pattern options:nil error:nil]; | |
NSTextCheckingResult *result = [expression firstMatchInString:string options:nil range:NSMakeRange(0, [string length])]; | |
return result.range; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment