美文网首页安卓小知识
Android最新手机号正则判断(含最新166/198/199开

Android最新手机号正则判断(含最新166/198/199开

作者: hao_developer | 来源:发表于2021-09-06 16:48 被阅读0次
/**
 * 匹配手机号的规则:[3578]是手机号第二位可能出现的数字
 */
public static final String REGEX_MOBILE = "^[1][3578][0-9]{9}$";

/**
 * 校验手机号
 * @param mobile
 * @return 校验通过返回true,否则返回false
 */
public static boolean isMobile(String mobile) {
    return Pattern.matches(REGEX_MOBILE, mobile);
}


1、手机号开头集合
166,
176,177,178
180,181,182,183,184,185,186,187,188,189  
145,147   
130,131,132,133,134,135,136,137,138,139  
150,151,152,153,155,156,157,158,159
198,199


2、正则表达式

public static boolean isChinaPhoneLegal(String str)  
            throws PatternSyntaxException {  
        String regExp = "^((13[0-9])|(15[^4])|(166)|(17[0-8])|(18[0-9])|(19[8-9])|(147,145))\\d{8}$"; 
        Pattern p = Pattern.compile(regExp);  
        Matcher m = p.matcher(str);  
        return m.matches();  
    }  

相关文章

网友评论

    本文标题:Android最新手机号正则判断(含最新166/198/199开

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