- (NSString *)filterWithString:(NSString *)str
{
NSString *regex = @"[^a-zA-Z0-9\u4e00-\u9fa5]";
return [str stringByReplacingOccurrencesOfString:regex withString:@"" options:NSRegularExpressionSearch range:NSMakeRange(0, str.length)];
}
一個更6 的黑科技
//過濾字符磚中的數(shù)字
- (NSString *)filterNmuberWithString:(NSString *)str
{
NSMutableString * mutableStr = [NSMutableString stringWithString:str];
NSString *newString = [[mutableStr componentsSeparatedByCharactersInSet:
[[NSCharacterSet letterCharacterSet] invertedSet]] componentsJoinedByString:@""];
return newString;
}
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者