Reputation: 533
I am trying to remove double quotes before square bracket like "[ and I am using following code to do it but it says illegal escape charecter.
str = str.replace("\[","[");
I want to remove only double quotes ie "
which is only before square bracket ie [
. Please guide me.
Upvotes: 1
Views: 3209
Reputation: 3175
Both replace()
and replaceAll()
do the job. Using replace
, you don't have to cope with regular expressions. Don't get confused by the name. In fact replace
replaces all occurrences, not just the first.
str = str.replace("\"[", "[");
Upvotes: 1