Regex removing double/triple comma in string

前端 未结 5 852
一生所求
一生所求 2021-02-15 00:39

I need to parse a string so the result should output like that:

\"abc,def,ghi,klm,nop\"

But the string I am receiving could looks more like tha

5条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-15 01:31

    a simple solution without regular expressions :

    string items = inputString.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
    string result = String.Join(",", items);
    

提交回复
热议问题