Optimize regex usage

This commit is contained in:
Timo Westkämper 2015-03-09 19:32:28 +02:00
parent 8a8cf8c66c
commit 67ff1abfeb

View File

@ -26,13 +26,13 @@ public final class Normalization {
// TODO simplify
private static final Pattern FULL_OPERATION = Pattern.compile(
"(?<![\\d\\*/\"\\?' ])" + "(\\b|\\(|\\s+)" +
"(?<![\\d*/\"?' ])" + "(\\b|\\(|\\s+)" +
"(" + NUMBER + WS + "[+\\-/*]" + WS + ")+" + NUMBER + WS +
"(?![\\d\\*/\"' ])");
"(?![\\d*/\"' ])");
private static final Pattern[] OPERATIONS = {
Pattern.compile(NUMBER + WS + "(\\*|/)" + WS + NUMBER),
Pattern.compile(NUMBER + WS + "(\\+|\\-)" + WS + NUMBER),
Pattern.compile(NUMBER + WS + "([*/])" + WS + NUMBER),
Pattern.compile(NUMBER + WS + "([+-])" + WS + NUMBER),
};
private static String normalizeOperation(String queryString) {