Kanaga Thara
Kanaga Thara

Reputation: 659

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\"");

Upvotes: 52

Views: 234498

Answers (3)

SpringLearner
SpringLearner

Reputation: 13844

Use replace method of string like the following way:

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

Output:

abcd

Upvotes: 26

Isuru Gunawardana
Isuru Gunawardana

Reputation: 2887

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

have a look here

Upvotes: 25

ssantos
ssantos

Reputation: 16526

You can just go for String replace method.-

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

Upvotes: 154

Related Questions