java - 从字符串中删除“\”对我不起作用
问题描述
我正在尝试从我的 ArrayList of Strings 中删除斜杠“\”,但是我不确定为什么它对我不起作用。
文本示例:
{"{\"Type\":\"CALM\",\"Confidence\":57.199989318847656}","{\"Type\":\"HAPPY\",\"Confidence\":38.17924880981445}",
我做错了什么?
for(int i = 0; i < mListUploadedImages.size(); i++){
String newEmotions = mListUploadedImages.get(i).getEmotions().replaceAll("\\'", "");
mListUploadedImages.get(i).setEmotions(newEmotions);
}
解决方案
你'
在“\\'”中多加一个。试试这个;
String newEmotions = mListUploadedImages.get(i).getEmotions().replace("\\", "");
推荐阅读
- typescript - 打字稿:如何访问和默认不存在的对象属性?
- c++ - Qt中整个项目的共享对象?
- macos - Mac 应用程序反复请求访问权限
- azure - 从文件夹开始复制 Azure 数据工厂
- jspdf - 在 jspdf-autotable 标题阿拉伯文文本中断
- c++ - 如何使用“一对中的一对”模板制作优先级队列?
- html - 修改基于 google doc/spreed 表的 HTML 文件以嵌入 instagram
- iptables - SSH 隧道 <--> iptables NAT 端口转发 - 如何?
- logic - 如何在 Coq Proof Assistant 中解构假设?
- python - QGIS python处理工具-保存/导出图形