キー/値ハッシュマップに値を格納します。キーの値が$で始まり、正規表現のreplaceAll呼び出しを実行すると、例外がスローされます。この例外を防ぐ理由と方法はありますか?値に「通常の」テキストが含まれる/始まる場合はエラーはありません
public static String ReplaceVariables(String argumentValue){
Pattern p = Pattern.compile("\\$\\{.*?\\}"); // find any text surrendered by "${" and "}"
while (true)
{
Matcher m = p.matcher(argumentValue);
if (!m.find()){
break; // no match found
}
String varName = m.group();
String varValue = GlobalUtilities.getVariable(varName); //get the hashmap value of the "varName" key
argumentValue = m.replaceAll(varValue); // replace all ${....} found by its hashmap value
}
return argumentValue; // return the new string
}