Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有字符串str="cooper"s towm",想转义字符串中的双引号(r 后的字符)。我正在使用str.replaceAll("\"","\\\"");,但是在 solr 中执行查询时,它仍然抛出解析异常。
str="cooper"s towm"
str.replaceAll("\"","\\\"");
请帮忙解决。谢谢。
你缺少一个反斜杠。
str.replaceAll("\"","\\"");
应该
str.replaceAll("\"","\\\\\"");