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\"");
To remove double quotes just from the beginning and end of the String, we can use a more specific regular expression: String result = input. replaceAll("^\"|\"$", ""); After executing this example, occurrences of double quotes at the beginning or at end of the String will be replaced by empty strings.
Use the String. replaceAll() method to remove all double quotes from a string, e.g. str. replaceAll('"', '') . The replace() method will return a new string with all double quotes removed.
There are four curly quote characters: the opening single quote ( ' ), the closing single quote ( ' ), the opening double quote ( “ ), and the closing double quote ( ” ).
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With