正则表达式
2017-11-14 本文已影响7人
coding_Liu
^[\u4E00-\u9FA5A-Za-z0-9]+$
除去特殊符号 只允许中文、英文字母、数字
//验证是否包含特殊字符
+(BOOL) SpecialCharactersValidateUserName:(NSString *)name
{
NSLog(@"name %@", name);
// "[^a-zA-Z0-9\u4E00-\u9FA5]"
NSString *userNameRegex = @"^[\u4E00-\u9FA5A-Za-z0-9]+$";
NSPredicate *userNamePredicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",userNameRegex];
BOOL B = [userNamePredicate evaluateWithObject:name];
return B;
}