简体   繁体   中英

Removing double quotes from a string in Java

How would I remove double quotes from a String?

For example: I would expect "abd to produce abd , without the double quote.

Here's the code I've tried:

line1 = line1.replaceAll("\"(\\b[^\"]+|\\s+)?\"(\\b[^\"]+\\b)?\"([^\"]+\\b|\\s+)?\"","\"$1$2$3\"");

You can just go for String replace method.-

line1 = line1.replace("\"", "");

Use replace method of string like the following way:

String x="\"abcd";
String z=x.replace("\"", "");
System.out.println(z);

Output:

abcd
String withoutQuotes_line1 = line1.replace("\"", "");

have a look here

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM