Browse Source

updated regex to include -numbers

Jonathan Hinds 6 years ago
parent
commit
dbfbb1bfeb
1 changed files with 2 additions and 1 deletions
  1. 2
    1
      Calculations.java

+ 2
- 1
Calculations.java View File

@@ -94,12 +94,13 @@ public class Calculations
94 94
             //return the array list
95 95
         //else return null'
96 96
         
97
-        Pattern pattern = Pattern.compile("\\s?\\.?\\d+\\.?(\\d+)?\\s?");
97
+        Pattern pattern = Pattern.compile("\\s?\\-?\\.?\\d+\\.?(\\d+)?\\s?");
98 98
         Matcher matcher = pattern.matcher(userInput);
99 99
         
100 100
         while(matcher.find()){
101 101
             String number = matcher.group().trim();
102 102
             Double deci = Double.valueOf(number);
103
+            System.out.println(deci);
103 104
             results.add(deci);
104 105
         }
105 106