In my Android app, I want to change the value of a String between double quotes. For example, I want to replace {"txt": with {"":
I have tried the following regex expressions, but they don’t work…
String abc=replace(str, "{\\txt\\:", "");
String abc=replace(str, "{'txt':", "");...,etc
Could anyone please offer help with this.
You need to escape each double-quote using a backslash.
Your question is a little ambiguous, so I’ll cover the two most reasonable interpretations of it:
If you want to replace
{"txt":with""(as stated in your question) then use this:With this code the text
{"txt":foo}becomes""foo}.If you want to replace
{"txt":with the empty string (as implied by your example code) then use this:With this code the text
{"txt":foo}becomesfoo}.