Przeglądaj źródła

1.工具类添加切割时间

hujing 5 lat temu
rodzic
commit
136d804087

+ 21 - 0
kernel/src/main/java/com/lantone/qc/kernel/util/CatalogueUtil.java

@@ -10,6 +10,8 @@ import org.springframework.stereotype.Component;
 
 import java.util.HashMap;
 import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 /**
  * @ClassName : CatalogueUtil
@@ -32,4 +34,23 @@ public class CatalogueUtil {
         }
         return content.replaceAll("[\r\n|/r/n|\n|/n|/t|\t]", "").trim();
     }
+
+    public static String[] extractDigit(String value) {
+        String[] res = new String[2];
+        try {
+            String regTime = "([\\d]+)([\\u4e00-\\u9fa5]+)";
+            Pattern pattern = Pattern.compile(regTime);
+            Matcher matcher = pattern.matcher(value);
+            if (matcher.find(0)) {
+                res[0] = matcher.group(1);
+                res[1] = matcher.group(2);
+            } else {
+                res[0] = value;
+                res[1] = "";
+            }
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+        return res;
+    }
 }