How to remove substring and comma if exist on left or right side

Viewed 154

I have the following string:

"house,car,table"

I need to properly handle the comma removal, so much so that If I remove "car" the output should be:

"house,table"

If I remove "table" the output should be:

"house,car"

4 Answers
Related