In C#: Add Quotes around string in a comma delimited list of strings

后端 未结 16 1938
被撕碎了的回忆
被撕碎了的回忆 2021-01-30 08:18

This probably has a simple answer, but I must not have had enough coffee to figure it out on my own:

If I had a comma delimited string such as:

string li         


        
16条回答
  •  粉色の甜心
    2021-01-30 08:50

    I can't write C# code, but this simple JavaScript code is probably easy to adapt:

    var s = "Fred,Sam,Mike,Sarah";
    alert(s.replace(/\b/g, "'"));
    

    It just replace bounds (start/end of string, transition from word chars non punctuation) by single quote.

提交回复
热议问题