开发中总是要用到手机号,就不免要判断手机号
- (BOOL) isVaildMobileNo:(NSString*)mobileNo
{
if(mobileNo.length!=11)returnNO;
NSString *phoneRegex = @"^((1[3456789]))\\d{9}$";
NSPredicate*phoneTest = [NSPredicatepredicateWithFormat:@"SELF MATCHES %@", phoneRegex];
return[phoneTestevaluateWithObject:mobileNo];
}
判断规则:
第一位必须是1
第二位3456789中间一个
后面9位为0-9之间数
网友评论