We Recommend

Programming in Objective-C Programming in Objective-C
Programming in Objective-C is a concise, carefully written tutorial on the basics of Objective-C and object-oriented programming. The book makes no assumption about prior experience with object-oriented programming languages or with the C language (upon which Objective-C is based). And because of this, both novice and experienced programmers alike can use this book to quickly and effectively learn the fundamentals of Objective-C.


Ballyhoo


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.