Objective-Cで正規表現を使いたい

NSPredicateを使って正規表現的なあれができるよ。

NSPredicate *regex = [NSPredicate predicateWithFormat:@"SELF matches %@", @"[hoge|fuga]+"];

NSString *s1 = @"hoge";
NSLog(@"%d", [regex evaluateWithObject:s1]); //=> YES

NSString *s2 = @"fuga";
NSLog(@"%d", [regex evaluateWithObject:s2]); //=> YES

NSString *s3 = @"hogefuga";
NSLog(@"%d", [regex evaluateWithObject:s3]); //=> YES

NSString *s4 = @"hogefugamoge";
NSLog(@"%d", [regex evaluateWithObject:s4]); //=> NO