#pragma mark 拨打号码
+(UIWebView *)callPhoneView:(NSString *)phone
{
NSURL *phoneURL = [NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",phone]];
UIWebView *phoneCallWebView = [[UIWebView alloc] initWithFrame:CGRectZero];
[phoneCallWebView loadRequest:[NSURLRequest requestWithURL:phoneURL]];
return phoneCallWebView;
}
#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];
BOOL bo= [emailTest evaluateWithObject:email];
return bo;
}
#pragma mark 手机合法验证
+(BOOL) isValidateMobile:(NSString *)mobile
{
//手机号以13, 15,18开头,八个 \d 数字字符
NSString *phoneRegex = @"^((13[0-9])|(15[^4,\\D])|(18[0,0-9]))\\d{8}$";
NSPredicate *phoneTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",phoneRegex];
return [phoneTest evaluateWithObject:mobile];
}
正则匹配,邮箱、电话号码合法性
最新推荐文章于 2023-05-30 11:35:43 发布