- (BOOL)containsUnCommonWord:(NSString *)content{
if(!content.length) return NO;
//过滤标点符号及常规字字符集,如果还存在字符串则默认含有生僻字
NSString *pattern = @"[\\u0020-\\u007E\\u00A0-\\u00BE\\u4e00-\\u9fa5\\p{P}+\\p{S}]";
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:pattern options:NSRegularExpressionCaseInsensitive error:nil];
NSString *modifiedString = [regex stringByReplacingMatchesInString:content
options:0
range:NSMakeRange(0, [content length])
withTemplate:@""];
NSLog(@"modifiedString = %@ isMatch = %d",modifiedString,!!modifiedString.length);
return !!modifiedString.length;
}
网友评论