Java手机号校验

    public static boolean verifyPhone(String phone) {
        String regex = "^[1]([3-9])[0-9]{9}$";
        boolean isMatch = false;
        if (StringUtils.isEmpty(phone)) {
            System.out.println("手机号不能为空");
        } else if (phone.length() != 11) {
            System.out.println("手机号应为11位数");
        } else {
            isMatch = Pattern.matches(regex, phone);
        }
        return isMatch;
    }

 

posted @ 2022-04-25 12:10  白玉神驹  阅读(4645)  评论(0)    收藏  举报