I have added the comments in the code for each function what I am trying to achieve here.
I am using escape
to match the value in url (where it will be encoded.) I am able to handle all the values except the values with decimals. For example if I have:
var s = "9%252E5|red|blue";
var itemToRemove = escape("9.5"); //escape to match the value in 's'.
As '.' can not be encoded/escaped I am not able to match the one with url, any ideas on how to deal this kind of an issue.