#pragma mark --判断手机号合法性
+ (BOOL)checkPhone:(NSString *)phoneNumber
{
NSString *regex = @"^((13[0-9])|(147)|(15[^4,\\D])|(18[0-9])|(17[0-9]))\\d{8}$";
NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
BOOL isMatch = [pred evaluateWithObject:phoneNumber];
if (!isMatch)
{
return NO;
}
return YES;
}
#pragma mark 判断邮箱
+ (BOOL)checkEmail:(NSString *)email{
//^(\\w)+(\\.\\w+)*@(\\w)+((\\.\\w{2,3}){1,3})$
NSString *regex = @"^[a-zA-Z0-9_-][email protected][a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$";
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
return [emailTest evaluateWithObject:email];
}
时间: 2024-10-23 15:35:46