美文网首页
iOS 利用正则函数判断手机号码(13,15,17,18字段)

iOS 利用正则函数判断手机号码(13,15,17,18字段)

作者: 孟维学 | 来源:发表于2016-07-22 11:42 被阅读36次

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

NSPredicate*pred = [NSPredicatepredicateWithFormat:@"SELF MATCHES %@", regex];

BOOLisMatch = [predevaluateWithObject:self.numtextfild.text];

if(!isMatch) {

UIAlertView* alert = [[UIAlertViewalloc]initWithTitle:@"提示"message:@"请输入正确的手机号码"delegate:nilcancelButtonTitle:@"OK"otherButtonTitles:nil,nil];

alert.tag=4369;

[alertshow];

return;

}

相关文章

网友评论

      本文标题:iOS 利用正则函数判断手机号码(13,15,17,18字段)

      本文链接:https://www.haomeiwen.com/subject/hbrijttx.html