Return to Snippet

Revision: 5251
at February 23, 2008 22:16 by zingo


Initial Code
NSString *mystring = @"Hello World!";
NSString *regex = @".*l{2,}.*";

NSPredicate *regextest = [NSPredicate
                         predicateWithFormat:@"SELF MATCHES %@", regex];

if ([regextest evaluateWithObject:mystring] == YES) {
    NSLog(@"Match!");
} else {
    NSLog(@"No match!");
}

Initial URL
http://www.stiefels.net/2007/01/24/regular-expressions-for-nsstring/

Initial Description


Initial Title
Testing Regular Expressions for NSString

Initial Tags
osx

Initial Language
Objective C