使用RegexKitLite使iphone也可以使用正则表达式

主要使用两个文件RegexKitLite.h和RegexKitLite.m,将文件拖进Xcode;

注意的是工程中要添加libicucore.dylib frameworks不然程序编译回报错;


在你想进行匹配的类里导入RegexKitLite.h后就可以使用了,例如匹配邮箱地址:


NSString *email = @”[email protected]”;
[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


iPhone/iPad 移动应用开发

iOS 程序员

你可能感兴趣的:(ios,正则表达式,xcode,iPhone,email)