1.手机验证是否有效
适用以13,19, 14(57), 17(0678), 15,18开头,8个 \d 数字字符
正则表达式:^((13[0-9])|(19[0-9])|(15[^4,\\D])|(17[0678])|(14[57])|(18[0,0-9]))\\d{8}$
代码如下:
NSString *phoneRegex = @"^((13[0-9])|(19[0-9])|(15[^4,\\D])|(17[0678])|(14[57])|(18[0,0-9]))\\d{8}$";
NSPredicate *phoneTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",phoneRegex];
Bool flag = [phoneTest evaluateWithObject:mobile];
flag = yes为有效,反之亦然。