I am retrieving data from a database, where the field contains a String with HTML data. I want to replace all of the double quotes such that it can be used for parseJSON of jQuery.
Using Java, I am trying to replace the quotes using..
details.replaceAll("\"","\\\"");
//details.replaceAll("\"",""e;"); details.replaceAll("\"",""");
The resultant string doesn’t show the desired change.
An O’Reilly article prescribes using Apache string utils. Is there any other way??
Is there a regex or something that I could use?
Here’s how
Note that strings are immutable, thus it is not sufficient to simply do
details.replace("\"","\\\""). You must reassign the variabledetailsto the resulting string.Using
instead, results in