现在的位置: 首页 > 综合 > 正文

[object-c]使用正则表达式

2013年08月08日 ⁄ 综合 ⁄ 共 272字 ⁄ 字号 评论关闭
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"); 

抱歉!评论已关闭.