I got String from the database which have multiple commas (,
) . I want to remove the last comma but I can\'t really find a simple way of doing it.
i am sharing code form my project using regular expression you can do this...
String ChildBelowList = "";
if (!Childbelow.isEmpty()) {
for (int iCB = 0; iCB < Childbelow.size(); iCB++) {
ChildBelowList = ChildBelowList += Childbelow.get(iCB) + ",";
}
ChildBelowList = ChildBelowList.replaceAll("(^(\\s*?\\,+)+\\s?)|(^\\s+)|(\\s+$)|((\\s*?\\,+)+\\s?$)", "");
tv_childbelow.setText(ChildBelowList);
} else {
ll_childbelow.setVisibility(View.GONE);
}