【发布时间】:2025-12-26 22:00:11
【问题描述】:
字符串的当前值为
^I am Shaikh with "([^"]*)" and "([^"]*)"$
我的代码如下:
System.out.println(strAnnotationValue); // prints ^I am Shaikh with "([^"]*)" and "([^"]*)"$
strAnnotationValue = strAnnotationValue.replaceAll("\"", "\\\"");
System.out.println(strAnnotationValue);
Actual Output: ^I am Shaikh with "([^"]*)" and "([^"]*)"$
Expected Output: ^I am Shaikh with \"([^\"]*)\" and \"([^\"]*)\"$
我已经编写了正确的代码,但它不起作用,还有其他方法可以做到这一点吗?
【问题讨论】:
-
温馨提示:如果您的代码不起作用,那么您编写的代码很可能不正确。
标签: java