string去除转义符
时间: 2023-09-22 11:10:24 浏览: 150
要去除字符串中的转义符,可以使用StringEscapeUtils类中的unescapeJava方法。这个方法可以将字符串中的转义字符转换回原始字符。例如,在代码中可以使用以下方法去除字符串中的转义符:
String str = "{\\\"name\\\":\\\"xiaoxu\\\",\\\"age\\\":\\\"27\\\"}";
String s = StringEscapeUtils.unescapeJava(str);
这样,s变量中的字符串就会去除转义符。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [java中字符串如何去掉转义字符](https://blog.csdn.net/weixin_55229531/article/details/130883639)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [去除String类型中的转义符](https://blog.csdn.net/m0_68072899/article/details/125316417)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文