Posted By

zingo on 02/23/08


Tagged

cocoa osx nsstring


Versions (?)

Testing Regular Expressions for NSString


 / Published in: Objective C
 

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

  1. NSString *mystring = @"Hello World!";
  2. NSString *regex = @".*l{2,}.*";
  3.  
  4. NSPredicate *regextest = [NSPredicate
  5. predicateWithFormat:@"SELF MATCHES %@", regex];
  6.  
  7. if ([regextest evaluateWithObject:mystring] == YES) {
  8. NSLog(@"Match!");
  9. } else {
  10. NSLog(@"No match!");
  11. }

Report this snippet  

You need to login to post a comment.