我不知道你有多少数量的数据,但似乎问题是replaceAll无法正常工作,因为我尝试过替换它并且工作得很棒。
String expression = "SUM_ALL(4:5,5:6)>MAX(6:7)
String mat = "";
Map functionOperators = new HashMap();
functionOperators.put("SUM_ALL(4:5,5:6)", 4.0);
functionOperators.put("MAX(6:7)",5.0);
Matcher m =
Pattern.compile(
"(?:(SUM_ALL|MAX|MIN)\\(((?:\\d+:\\d+,?){1,2})\\)[+->
.matcher(expression);
while (m.find()) {
mat = String.format("%s(%s)", m.group(1), m.group(2));
expression = expression.replace(mat, functionOperators.get(mat).toString());
}
System.out.println(expression);直接取自你之前的例子(昨天)