lihong 1 年之前
父節點
當前提交
379cdcdcff
共有 1 個文件被更改,包括 5 次插入11 次删除
  1. 5 11
      src/main/java/cn/hnthyy/thmz/Utils/StringUtil.java

+ 5 - 11
src/main/java/cn/hnthyy/thmz/Utils/StringUtil.java

@@ -1,6 +1,8 @@
 package cn.hnthyy.thmz.Utils;
 
 import cn.hutool.core.io.IoUtil;
+import cn.hutool.core.lang.Validator;
+import cn.hutool.core.util.PhoneUtil;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.util.PropertyPlaceholderHelper;
 
@@ -200,18 +202,10 @@ public class StringUtil {
      * @return
      */
     public static String isPhone(String phone) {
-        String regex = "^((13[0-9])|(14[5,7,9])|(15([0-3]|[5-9]))|(166)|(17[0,2,1,3,5,6,7,8])|(18[0-9])|(19[1|3|5|8|9]))\\d{8}$";
-        if (phone.length() != 11) {
-            return "手机号应为11位数";
-        } else {
-            Pattern p = Pattern.compile(regex);
-            Matcher m = p.matcher(phone);
-            boolean isMatch = m.matches();
-            if (!isMatch) {
-                return "请填入正确的手机号";
-            }
-            return null;
+        if(!PhoneUtil.isPhone(phone)){
+            return "请填入正确的手机号";
         }
+        return null;
     }