JAVA 正则表达式验证手机号码

String regex = "^1[345678]\\d{9}$";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher("111111111111");
        if(!matcher.matches()){
            System.out.println("格式不正确");
        }

 

posted @ 2021-12-14 11:23  哎丫丫呀喂  阅读(1850)  评论(0编辑  收藏  举报