手机号判断

作者: 此时_此景 | 来源:发表于2018-06-19 15:30 被阅读1次

开发中总是要用到手机号,就不免要判断手机号

- (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之间数

相关文章

网友评论

    本文标题:手机号判断

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