zhoutg před 4 roky
rodič
revize
4b0aa8701f

+ 4 - 23
src/main/java/com/diagbot/model/ai/process/EntityProcess.java

@@ -377,12 +377,12 @@ public class EntityProcess {
     public String[] extract_digit_new(String value) {
         String[] res = new String[2];
         try {
-            String reg_time = "([1-9]\\d*\\.?\\d*)|(0\\.\\d*[1-9])";
-            Pattern pattern = Pattern.compile(reg_time);
+            String regex = "([1-9]\\d*\\.?\\d*)|(0\\.\\d*[1-9])";
+            Pattern pattern = Pattern.compile(regex);
             Matcher matcher = pattern.matcher(value);
             if (matcher.find(0)) {
-                res[0] = matcher.group(1);
-                res[1] = value.substring(value.indexOf(res[0]) + res[0].length());
+                res[0] = matcher.group(0);
+                res[1] = value.substring(matcher.end(0));
             } else {
                 res[0] = value;
                 res[1] = "";
@@ -392,23 +392,4 @@ public class EntityProcess {
         }
         return res;
     }
-
-    public static void main(String[] args) {
-        String value = "℃";
-        String[] res = new String[2];
-        try {
-            String reg_time = "([1-9]\\d*\\.?\\d*)|(0\\.\\d*[1-9])";
-            Pattern pattern = Pattern.compile(reg_time);
-            Matcher matcher = pattern.matcher(value);
-            if (matcher.find(0)) {
-                res[0] = matcher.group(1);
-                res[1] = value.substring(value.indexOf(res[0]) + res[0].length());
-            } else {
-                res[0] = value;
-                res[1] = "";
-            }
-        } catch (Exception ex) {
-            ex.printStackTrace();
-        }
-    }
 }