Reputation: 357
how can I remove Quotation mark using regex? I tried to implement it to the replace in strings but I went outside the like adding a string. I dont know how to replace it I just want to take all the Quotation mark and replace it with blank string
data.replace(""", ")
that one wont work
Upvotes: 3
Views: 13238
Reputation: 1981
You must escape the quotes first!
To replace using a regex do this:
"\"This is some text\"".replaceAll("\"", "");
Upvotes: 1
Reputation: 5758
In regex, '
is a metacharacter , hence you have to escape it with a \
try this :
str = str.replaceAll("\'", "");
or for a double quote:
str = str.replaceAll("\"", "");
Upvotes: 0
Reputation: 248
you need to escape the quote with a '\'
String quoted = "\"quoted text\"";
quoted.replace("\"", "");
Upvotes: 5