#pragma mark 判断邮箱的
+(BOOL)isValidateEmail:(NSString *)email
{
NSString *emailRegex = @"[A-Z0-9a-z._%+-][email protected][A-Za-z0-9.-]+\\\\.[A-Za-z]{2,4}";
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
return [emailTest evaluateWithObject:email];
}
#pragma mark QQ号码
+ (BOOL) validateQQ:(NSString *)email
{
NSString *emailRegex = @"^\\\\d{5,12}$";
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
return [emailTest evaluateWithObject:email];
}
#pragma mark ***号
+ (BOOL) validateIdentityCard: (NSString *)identityCard
{
BOOL flag;
if (identityCard.length <= 0) {
flag = NO;
return flag;
}
NSString *regex2 = @"^(\\\\d{14}|\\\\d{17})(\\\\d|[xX])$";
NSPredicate *identityCardPredicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex2];
return [identityCardPredicate evaluateWithObject:identityCard];
}
#pragma mark 判断昵称的
+ (BOOL) validateNickname:(NSString *)nickname
{
NSString *phoneRegex = @"[\\u4e00-\\u9fa5]{2,7}";
NSPredicate *phoneTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",phoneRegex];
return [phoneTest evaluateWithObject:nickname];
}
手机号码的那个正则,网上的几乎都不好用,都有bug,所以建议还还是判断手机号11位,是不是1开头的,我感觉就可以了,只能是数字