使用正则表达式限制输入字符为中文、英文、数字
2015-12-03 本文已影响109人
小雨hahaha
NSString *regex = @"[0-9a-zA-Z\\u4e00-\\u9fa5]+$";
NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
if (![pred evaluateWithObject:textView.text]) {
[SVProgressHUD showInfoWithStatus:@"标签只能由中文、英文、数字组成"];
}