正则表达式判断手机号码

前端之家收集整理的这篇文章主要介绍了正则表达式判断手机号码前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

//判断手机号是否符合

if(![self isValidateMobile:phoneNumber])

{

UIAlertView * alert = [[UIAlertView alloc]initWithTitle:nil message:@"请输入正确的手机号码" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:@"取消",nil];

[alert show];

return;

}

/*手机号码验证 MODIFIED BY HELENSONG*/

-(BOOL) isValidateMobile:(NSString *)mobile

{

//手机号以13 1518开头,八个 \d 数字字符

NSString *phoneRegex =@"^((13[0-9])|(15[^4,\\D])|(18[0,0-9]))\\d{8}$";

NSPredicate *phoneTest = [NSPredicatepredicateWithFormat:@"SELF MATCHES %@",phoneRegex];

// NSLog(@"phoneTest is %@",phoneTest);

return [phoneTest evaluateWithObject:mobile];

}

原文链接:https://www.f2er.com/regex/360937.html

猜你在找的正则表达式相关文章