IOS中使用正则表达式

NSString * regex        = @"^.*\"success\":false{1}.*$";
NSPredicate * pred      = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
BOOL isMatch            = [pred evaluateWithObject:@"\"loginCallback({\"sS\":\"101\",\"iI\":false,\"iP\":true,\"success\":false});\""];
NSLog (@"%s", (isMatch) ? "YES" : "NO"); 

posted on 2012-11-29 12:05  南瓜饼  阅读(155)  评论(0编辑  收藏  举报

导航