java replaceall的问题

2025年03月23日 17:37
有2个网友回答
网友(1):

public static void main(String[] args) {
String test = "a\"b";

test = test.replaceAll("\"", "\\\\\"");
System.out.println(test);
}

网友(2):

String s = "a\"b";
System.out.println(s.replace("\"", "\\\""));