加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

正则表达式判断手机号码

发布时间:2020-12-14 01:29:03 所属栏目:百科 来源:网络整理
导读://判断手机号是否符合 if (![ self isValidateMobile :phoneNumber]) { UIAlertView * alert = [[ UIAlertView alloc ] initWithTitle : nil message : @" 请输入正确的手机号码 " delegate : nil cancelButtonTitle : @" 确定 " otherButtonTitles : @" 取

//判断手机号是否符合

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];

}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读