对于这个简单的程序...
import java.lang.String;
public class test {
public static void main(String[] argv) {
String s = "Hello <BSLASH>";
String sReplaced = s.replaceAll("<BSLASH>", "\\\\");
System.out.println("s = " + s);
System.out.println("sReplaced = " + sReplaced);
}
}
为什么 sReplaced 不等于带有 2 个反斜杠的 Hello \\ ?
$javac test.java
$ java test
s = Hello <BSLASH>
sReplaced = Hello \