运行是你想要的结果!
string str = "sdfsdf,dsfsdf?,dsfsdfsd,dfsdfsdf,dfs?dsfsd";
            string strTmp = "";
            string[] strAll = str.Split(',');
            for (int i = 0; i < strAll.Length; i++)
            {
                Regex reg = new Regex("[?/]+");
                Match m = reg.Match(strAll[i]);
                if (!m.Success)
                {
                    strTmp += strAll[i] + ",";
                }
                else
                {
                    strTmp += "'" + strAll[i] + "',";
                }
            }
            MessageBox.Show(strTmp);

解决方案 »

  1.   


    string a = "sdfsdf,dsfsdf?,dsfsdfsd,dfsdfsdf,dfs?dsfsd";
    string b = null;
    a.Split(',').ToList().ForEach(o => b += o.Contains("?") ? "\"" + o + "\"," : o + ",");
    Console.WriteLine(b.Remove(b.Length - 1, 1));
      

  2.   

                string str = "sdfsdf,dsfsdf?,dsfsdfsd,dfsdfsdf,dfs?dsfsd";
                string result = Regex.Replace(str, @"(?<word>\w*[?]\w*)", "\"" + "${word}" + "\"");