How to check if string matches a regular expression in objective-c?
since regular exressions are not supported in Cocoa I find RegexKitLite very usefull. But all examples extract matching strings. I just want to test if a string matches a regular expression and get a Yes or No. How can I do that? I've used NSPredicate for that purpose: NSString *someRegexp = ...; NSPredicate *myTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", someRegexp]; if ([myTest evaluateWithObject: testString]){ //Matches } Another way to do this, which is a bit simpler than using NSPredicate , is an almost undocumented option to NSString's -rangeOfString:options: : NSRange