java replaceall的问题

2025-03-23 17:37:12
推荐回答(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("\"", "\\\""));