限制不能输入中文
2020-01-08 本文已影响0人
Bruin_熊先森
NSString*str = fd.text;
for(inti =0; i
NSString*string = [strsubstringFromIndex:i];
NSString *regex = @"[\u4e00-\u9fa5]{0,}$"; // 中文
// 2、拼接谓词
NSPredicate *predicateRe1 = [NSPredicate predicateWithFormat:@"self matches %@", regex];
// 3、匹配字符串
BOOLresualt = [predicateRe1evaluateWithObject:string];
if(resualt){
str = [strstringByReplacingOccurrencesOfString:[str substringFromIndex:i] withString:@""];
}
}