Vincent Gable’s Blog

September 20, 2008

Regex Matching and Filtering in Cocoa With NSPredicate

Filed under: Cocoa,MacOSX,Objective-C,Programming | , , ,
― Vincent Gable on September 20, 2008

Apples documentation of Regular Expressions With NSPredicate has the full scoop, but basically you do
[NSPredicate predicateWithFormat:@"SELF MATCHES regex-here"];. Unfortunately, you can only test if strings match a regex. You can not use an NSPredicate-regex to extract parts of a string. Depending on what you need to do, this may or may not be enough to save the day.

Powered by WordPress