NSString *regex = @"[0-9a-zA-Z\\u4e00-\\u9fa5]+$";
NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
if (![pred evaluateWithObject:textView.text]) {
[SVProgressHUD showInfoWithStatus:@"标签只能由中文、英文、数字组成"];
}
NSString *regex = @"[0-9a-zA-Z\\u4e00-\\u9fa5]+$";
NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
if (![pred evaluateWithObject:textView.text]) {
[SVProgressHUD showInfoWithStatus:@"标签只能由中文、英文、数字组成"];
}
本文标题:使用正则表达式限制输入字符为中文、英文、数字
本文链接:https://www.haomeiwen.com/subject/uajshttx.html
网友评论