iOS手机号正则

作者: 少少少少少少少 | 来源:发表于2016-05-03 14:05 被阅读373次
//  手机号正则
NSString *mobileRegex = @"[1][34578][0-9]{9}";
NSPredicate *mobilePredicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", mobileRegex];
    
 if (!_phoneTF.text || ![mobilePredicate evaluateWithObject:_phoneTF.text]) {
        
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"请输入正确的手机号码"
                                                        message:@""
                                                       delegate:self
                                              cancelButtonTitle:@"确定"
                                              otherButtonTitles:nil, nil];
        [alert show];
        return;
    }```

相关文章

网友评论

    本文标题:iOS手机号正则

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