Created
September 26, 2011 19:25
-
-
Save nomothetis/1243140 to your computer and use it in GitHub Desktop.
Search-and-replace with Regexes in Objective-C.
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
NSError *err = nil; | |
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"%%.*?%%" options:0 error:&err]; | |
if (!regex) { | |
[NSException raise:@"badRegularExpression" | |
format:@"The regular expression was incorrectly constructed. Error was: %@", err]; | |
} | |
[regex replaceMatchesInString:aMutableString options:0 range:NSMakeRange(0, newURL.length) withTemplate:@""]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment