Skip to content

Commit

Permalink
Make sure to replace the correct thing
Browse files Browse the repository at this point in the history
  • Loading branch information
Earthcomputer committed Sep 16, 2023
1 parent 890a9e9 commit 6ab4f6c
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ private static void loadFile() throws IOException {
}

public static String replaceVariables(String originalString) {
Matcher matcher = VARIABLE_PATTERN.matcher(originalString.replace("\\", "\\\\").replace("$", "\\$"));
Matcher matcher = VARIABLE_PATTERN.matcher(originalString);
StringBuilder builder = new StringBuilder();
while (matcher.find()) {
String group = matcher.group();
matcher.appendReplacement(builder, variables.getOrDefault(group.substring(1, group.length() - 1), group));
matcher.appendReplacement(builder, variables.getOrDefault(group.substring(1, group.length() - 1), group).replace("\\", "\\\\").replace("$", "\\$"));
}
matcher.appendTail(builder);
return builder.toString();
Expand Down

0 comments on commit 6ab4f6c

Please sign in to comment.