从Java中的字符串中删除双引号
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19316394/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 16:01:58 来源:igfitidea点击:
Removing double quotes from a string in Java
提问by Kanaga Thara
How would I remove double quotes from a String?
如何从字符串中删除双引号?
For example: I would expect "abd
to produce abd
, without the double quote.
例如:我希望"abd
生产abd
,没有双引号。
Here's the code I've tried:
这是我试过的代码:
line1 = line1.replaceAll("\"(\b[^\"]+|\s+)?\"(\b[^\"]+\b)?\"([^\"]+\b|\s+)?\"","\"\"");
回答by ssantos
回答by SpringLearner
Use replace method of string like the following way:
像下面这样使用字符串的替换方法:
String x="\"abcd";
String z=x.replace("\"", "");
System.out.println(z);
Output:
输出:
abcd