- (BOOL)verifyKeyword:(NSString *)keyword
{
BOOL isMatch = NO;
NSString * regex = @"[\u4e00-\u9fa5a-zA-Z0-9\\s]*"; // 匹配汉字,字母和空格
NSPredicate * pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
isMatch = [pred evaluateWithObject:keyword];
return isMatch;
}
更改regex,可以匹配到自己需要的。
原文:http://my.oschina.net/wwq1001/blog/412511