public boolean verifyPhone(String phone) {
       String regex = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(17[013678])|(18[0,5-9]))\\d{8}$";
        if (phone.length() != 11) {
            System.out.println("手机号应为11位数");
        } else {
           Pattern p = Pattern.compile(regex);
            Matcher m = p.matcher(phone);
            boolean isMatch = m.matches();
            if (isMatch) {
                log.info("手机号格式正确");
                return true;
            } else {
                log.info("手机号格式错误");
            }
        }
        return false;
    }

相关文章:

  • 2022-02-03
  • 2022-01-11
  • 2021-12-23
  • 2021-12-23
  • 2022-02-04
  • 2021-10-12
  • 2021-06-26
猜你喜欢
  • 2022-02-09
  • 2022-01-10
  • 2021-10-18
  • 2022-02-17
  • 2021-12-23
  • 2021-12-21
相关资源
相似解决方案