I am creating an application in which I created a line as follows:
hihibjj,,,,,,,ghjjjj, , ,kartik.isworking@gmail.com,,,,karan.adep@gmail.com, android-developer-support@google.com, prerna.mungekar@hamarisuraksha.com
I want to remove unnecessary commas, only separate values should be present, separated by a comma.
The code I 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();
}
}
}
source
share