diff options
author | Adrien Hopkins <masterofnumbers17@gmail.com> | 2019-11-26 20:53:27 -0500 |
---|---|---|
committer | Adrien Hopkins <masterofnumbers17@gmail.com> | 2019-11-26 20:53:27 -0500 |
commit | bff8f363ce5e2ca84da1d57a470f0648c4b338e6 (patch) | |
tree | 79e229cb9648c288aa8fcb5beb731c04ecf82573 /src/org/unitConverter/unit/UnitDatabase.java | |
parent | 7a0f427727db7fcafd389e1e2c4b3ab207acd5c2 (diff) |
Prefixes can now have names.
Diffstat (limited to 'src/org/unitConverter/unit/UnitDatabase.java')
-rw-r--r-- | src/org/unitConverter/unit/UnitDatabase.java | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/org/unitConverter/unit/UnitDatabase.java b/src/org/unitConverter/unit/UnitDatabase.java index 6a89b67..9df34a7 100644 --- a/src/org/unitConverter/unit/UnitDatabase.java +++ b/src/org/unitConverter/unit/UnitDatabase.java @@ -974,12 +974,13 @@ public final class UnitDatabase { */ private static final Map<Pattern, String> EXPRESSION_REPLACEMENTS = new HashMap<>(); + // add data to expression replacements 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 + "\\s*" // optional space(s) - + "([a-zA-Z]+)" // unit name + + "([a-zA-Z]+)" // any string of letters + "(?!-?\\d)" // no number directly afterwards (avoids matching "1e3") ), "\\($1 $2\\)"); } |