java验证手机号格式


  String regex = "^((13[0-9])|(14[5,7,9])|(15([0-3]|[5-9]))|(17[0,1,3,5,6,7,8])|(18[0-9])|(19[8|9])|(16[6]))\\d{8}$";
  Pattern p = Pattern.compile(regex);
  Matcher m = p.matcher(registrant_phone);  //registrant_phone  ====  电话号码字段
  boolean isMatch = m.matches();
  if (!isMatch) {
     msg.errorCode = 1;
     msg.msg = "手机号格式不正确";

  }else{

    执行方法;

        }


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM