如何使用Java的String.replaceAll方法替换以$开头的String

use*_*890 2 java regex string

什么是以$ char开头的String作为String类中Java的replaceAll方法的第一个参数(即要替换的字符串)的正确正则表达式是什么?我无法正确理解语法.例

String s = "SUMIF($C$6:$C$475,\"   India - Hyd\",K$6:K$475)";
System.out.println(s.replaceAll("$475", "$44"));
Run Code Online (Sandbox Code Playgroud)

shm*_*sel 7

在这种情况下,我建议您使用replace()而不是replaceAll(),因为您没有使用任何正则表达式:

System.out.println(s.replace("$475", "$44"));
Run Code Online (Sandbox Code Playgroud)