remove value from comma separated values string

前端 未结 9 1822
不知归路
不知归路 2020-12-30 05:27

I have a csv string like this \"1,2,3\" and want to be able to remove a desired value from it.

For example if I want to remove the value: 2, the output string should

9条回答
  •  感情败类
    2020-12-30 06:28

    function process(csv,valueToDelete) {
      var tmp = ","+csv;
      tmp = tmp.replace(","+valueToDelete,"");
      if (tmp.substr(0,1) == ',') tmp = tmp.substr(1);
      return tmp;
    }
    

提交回复
热议问题