您好,登录后才能下订单哦!
#pragma mark 判断邮箱的
+(BOOL)isValidateEmail:(NSString *)email
{
NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[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开头的,我感觉就可以了,只能是数字
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。