手机号码正则验证(试用版)
发布时间:2020-12-14 01:25:39  所属栏目:百科  来源:网络整理 
            导读://手机号码正则验证- (BOOL)checkTel:(NSString *)str{ if ([str length] == 0) { [self showAlertView:@"请输入手机号码"]; return NO; } NSString *regex = @"^((13[0-9])|(147)|(15[^4,D])|(18[0,5-9]))d{8}$"; NSPredicate *pred = [NSPredicate pre
                
                
                
            | //手机号码正则验证
- (BOOL)checkTel:(NSString *)str
{
    if ([str length] == 0) {
        [self showAlertView:@"请输入手机号码"];
        return NO;
    }
    NSString *regex = @"^((13[0-9])|(147)|(15[^4,D])|(18[0,5-9]))d{8}$";
    NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex];
    BOOL isMatch = [pred evaluateWithObject:str];
    if (!isMatch) {
        [self showAlertView:@"手机号码输入有误"];
        return NO;
    }else {
        [self showAlertView:@"修改成功"];
    }
    return YES;
}
- (void)showAlertView:(NSString *)string {
    UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"提示" message:string delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil,nil];
    [alertView show];
}(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! | 
