I have a String with single quote. I want to replace the single quote with 2 single quotes. I tried using
String s="Kathleen D'Souza";
s.replaceAll("'","''");
s.replaceAll("\'","\'\'");
s.replace("'","''");
s.replace("\'","\'\'");
But the single quote is not getting replaced with 2 single quotes.
reassign the replaced string to s
String s="Kathleen D'Souza";
s = s.replaceAll("'","''");
Please try s= "test ' test";
`s.replaceAll("'","\"");` => test " test
`s.replaceAll("'","''");` => test '' test
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With