首页 > 解决方案 > 从字符串中删除“\”对我不起作用

问题描述

我正在尝试从我的 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);
}

标签: java

解决方案


'在“\\'”中多加一个。试试这个;

String newEmotions = mListUploadedImages.get(i).getEmotions().replace("\\", "");

推荐阅读