主要使用两个文件RegexKitLite.h和RegexKitLite.m,将文件拖进Xcode;
注意的是工程中要添加libicucore.dylib frameworks不然程序编译回报错;
在你想进行匹配的类里导入RegexKitLite.h后就可以使用了,例如匹配邮箱地址:
NSString *email = @”address@mail.com”;
[email isMatchedByRegex:@"\\b([a-zA-Z0-9%_.+\\-]+)@([a-zA-Z0-9.\\-]+?\\.[a-zA-Z]{2,6})\\b”];
方法 isMatchedByRegex会返回BOOL值,yes是匹配,no是不匹配;
附件下载地址:
http://download.csdn.net/source/3491190