java中replaceAll方法替换字符串中的反斜杠 String str = "\"; str = str.replaceAll("\\","|\\"); System.out.println(str); 参考 https://www.cnblogs.com/xdp-gacl/p/3912784.html