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
             //return the array list
94
             //return the array list
95
         //else return null'
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
         Matcher matcher = pattern.matcher(userInput);
98
         Matcher matcher = pattern.matcher(userInput);
99
         
99
         
100
         while(matcher.find()){
100
         while(matcher.find()){
101
             String number = matcher.group().trim();
101
             String number = matcher.group().trim();
102
             Double deci = Double.valueOf(number);
102
             Double deci = Double.valueOf(number);
103
+            System.out.println(deci);
103
             results.add(deci);
104
             results.add(deci);
104
         }
105
         }
105
         
106