public static String template = "$A$B"
public static void somemethod() {
template.replaceAll(Matcher.quoteReplacement("$")+"A", "A");
template.replaceAll(Matcher.quoteReplacement("$")+"B", "B");
//throws java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 3
template.replaceAll("\\$A", "A");
template.replaceAll("\\$B", "B");
//the same behavior
template.replace("$A", "A");
template.replace("$B", "B");
//template is still "$A$B"
}
我不明白。我使用了所有可以在互联网上找到的替换方法,包括我能找到的所有堆栈溢出。我什至试过\u0024!怎么了?