Skip to content

Instantly share code, notes, and snippets.

@aiwilliams
Created October 8, 2010 20:20
Show Gist options
  • Save aiwilliams/617462 to your computer and use it in GitHub Desktop.
Save aiwilliams/617462 to your computer and use it in GitHub Desktop.
Purist NS Regexp (Predicate)
NSString *actual = @"actual string";
NSString *regex = @"^actual string$";
NSPredicate *regextest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
BOOL isMatch = [regextest evaluateWithObject:actual];
STAssertTrue(isMatch, @"Expected %@ to match %@", actual, regex);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment