Reputation: 1219
I have a String can’t
in StringBuffer(i.e. sb).
I want to change it to cant't
But when I try
sb.replace(0, sb.length(),( (sb.toString()).replaceAll("’","'")));
it gives me o/p at cant’t
.
Upvotes: 0
Views: 1175
Reputation: 4580
sb = new StringBuffer(sb.toString().replaceAll("’", "'"));
Please try this.
Upvotes: 1
Reputation: 128428
You can define string with ' character inside the in Strings.xml file:
For example:
<string name="good_example">"This'll work"</string>
<string name="good_example_2">This\'ll also work</string>
For more info, check this Android SDK: String R
Upvotes: 0
Reputation: 19796
Try this sb = sb.replace(0, sb.length(),( (sb.toString()).replaceAll("’","'")));
Upvotes: 0