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