I am creating an app in which I have generated string like this:
hihibjj,,,,,,,ghjjjj, , ,[email protected],,,,[email protected], [email protected], [email protected]
What I want is to delete unwanted commas, only single comma separated values should be present.
Code that I have tried
for (int i = 0; i < temp.length; i++) {
for (int j = 0; j < emailSeperated.size(); j++) {
if (temp[i].trim().equals(emailSeperated.get(j).trim())) {
strEmailValue = strEmailValue.replace(temp[i], "").trim();
Log.e("strEmail trimmed value", strEmailValue);
} else if (temp[i].trim().equals(emailSeperated.get(j).trim())) {
strEmailValue = strEmailValue.replaceAll(temp[i] + ",", "").trim();
}
}
}
Just find: ,,+
and replace with: ,
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