diff options
author | Adrien Hopkins <masterofnumbers17@gmail.com> | 2019-11-28 14:16:02 -0500 |
---|---|---|
committer | Adrien Hopkins <masterofnumbers17@gmail.com> | 2019-11-28 14:16:02 -0500 |
commit | e1e7e38482de8cf8f6d4fd8735b6e43ad2a13cb8 (patch) | |
tree | 11b2268eaa0a3fd56669b90516daca3e49de3b63 /src/org/unitConverter/unit | |
parent | 908a9024f13a24def5d5e82ea08f7b5257a0426c (diff) |
You can now perform reciprocal conversions (e.g. s <-> Hz)
Fixed some bugs in unit-number ordering ("10 m^2" was interpreted as
"(10 m)^2", e-notation was ignored)
Diffstat (limited to 'src/org/unitConverter/unit')
-rw-r--r-- | src/org/unitConverter/unit/UnitDatabase.java | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/org/unitConverter/unit/UnitDatabase.java b/src/org/unitConverter/unit/UnitDatabase.java index 9df34a7..65d52bf 100644 --- a/src/org/unitConverter/unit/UnitDatabase.java +++ b/src/org/unitConverter/unit/UnitDatabase.java @@ -978,9 +978,10 @@ public final class UnitDatabase { static { // place brackets around any expression of the form "number unit", with or without the space EXPRESSION_REPLACEMENTS.put(Pattern.compile("((?:-?[1-9]\\d*|0)" // integer - + "(?:\\.\\d+)?)" // optional decimal point with numbers after it + + "(?:\\.\\d+(?:[eE]\\d+))?)" // optional decimal point with numbers after it + "\\s*" // optional space(s) - + "([a-zA-Z]+)" // any string of letters + + "([a-zA-Z]+(?:\\^\\d+)?" // any string of letters + + "(?:\\s+[a-zA-Z]+(?:\\^\\d+)?))" // optional other letters + "(?!-?\\d)" // no number directly afterwards (avoids matching "1e3") ), "\\($1 $2\\)"); } @@ -1473,8 +1474,6 @@ public final class UnitDatabase { modifiedExpression = replacement.getKey().matcher(modifiedExpression).replaceAll(replacement.getValue()); } - System.out.println(modifiedExpression); - return this.prefixExpressionParser.parseExpression(modifiedExpression); } |