My server json result is "abcde"
(it contains "
).
How to remove "
? This is not working.
System.out.print(result.replaceAll("\"\",""));
不要使用replaceAll(String regex, String replacement)
因为它接受正则表达式作为第一个参数(你不需要它),使用replace(CharSequence target, CharSequence replacement)
代替:
System.out.print(result.replace("\"",""));
尝试使用:
System.out.println(result.replace("\"",""));
尝试这个:
System.out.print("abcde".replaceAll("\\"",""));
I am not sure why the other solutions do not work, but just for the sake of being thorough, can you check with replaceAll("\\\\\\"",""));
Since replaceAll
method expects a regular expression!
Seeing that the other answers don't work for you, you could always remove the "
manually. By removing the first character and the last one.
String str = "\"abdc\"";
str.substring(1, str.length()-1);
It a bit of a hack, not sure if has the same efficiency of replace.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.