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"
}
잘 모르겠습니다. 내가 찾은 모든 스택 오버 플로우를 포함하여 internets에서 찾을 수있는 대체 방법을 사용했습니다. 심지어 \ u0024 시도! 뭐가 문제 야?Java replaceAll/string을 달러 기호 인 인스턴스로 바꾸십시오.
DAMN! 나는 그것을 올바른 방법으로 전에 수천 번처럼했습니다. 방금 잊었 어! 감사! – emha
@emha 답이 유용 할 경우 수락하지 않으시겠습니까? – RAS