I have String like this:
String strCustom1 = "Red, Green, Blue";
I have tried this, but replacing all the ,
with and
strCustom = "Red, Green, Blue";
strCustom = strCustom.replaceAll(",", " and");
[or]
strCustom = strCustom.replace(",", " and");
Like this:
Red and Blue and Green
But I just want to replace last ,
with space+and
So it should look this:
Red, Green and Blue
In a same way, want to format this:
String strCustom2 = "Red, Green, Blue, Yellow";
and as a result i want to get this:
Red, Green, Blue and Yellow