Skip to content

Commit

Permalink
fix: CustomFunction.replaceTargets replaces too much
Browse files Browse the repository at this point in the history
Signed-off-by: tangyang9464 <[email protected]>
  • Loading branch information
tangyang9464 committed Jul 13, 2021
1 parent c5e5a0f commit 02e463f
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public abstract class CustomFunction extends AbstractFunction {
private AviatorEvaluatorInstance aviatorEval;

public String replaceTargets(String exp, Map<String, Object> env) {
for (String key : env.keySet()) {
int index;
if ((index = key.indexOf('_')) != -1) {
String s = key.substring(index + 1);
exp = exp.replace("." + s, "_" + s);
}
//Replace the first dot, because it can't be recognized by the 'reg' below.
if (exp.startsWith( "r") || exp.startsWith( "p")) {
exp = exp.replaceFirst("\\.","_");
}
//match example: "&&r.","||r.","=r."
String reg = "([| =)(&<>,+\\-*/!])((r|p)[0-9]*)\\.";
exp = exp.replaceAll(reg,"$1$2_");
return exp;
}

Expand Down

0 comments on commit 02e463f

Please sign in to comment.