string result = Regex.Replace("内容", @"([\w]*?,[\w]+)", "\"$1\"");

解决方案 »

  1.   

    str=Regex.Replace(str,@"\w+,\w+","'$0'");
      

  2.   

    不符合啊 "Time:2013-11-11 10:54.41\r\nPoint\tZ\t\r\n{X=-147, Y=0}\t1660.9\t\r\n{X=-141.12, Y=0}\t1660.9\t\r\n{X=-135.24, Y=0}\t1660.9\t\r\n"对这个字符串 希望匹配后能变成
    "Time:2013-11-11 10:54.41
    Point Z
    '{X=-147, Y=0} '1660.9
    '{X=-141.12, Y=0} '1660.9
    '{X=-135.24, Y=0} '1660.9"
      

  3.   

    还是不行我是想把一个字符串
    "Time:2013-11-11 10:54.41\r\nPoint\tZ\t\r\n{X=-147, Y=0}\t1660.9\t\r\n{X=-141.12, Y=0}\t1660.9\t\r\n{X=-135.24, Y=0}\t1660.9\t\r\n"写到CSV文件里头,这样显示唉..:
    Time              2013-11-11 10:54.41
    Point             Z
    {X=-147, Y=0}     1660.9
    {X=-141.12, Y=0}  1660.9
    {X=-135.24, Y=0}  1660.9
      

  4.   

    不符合啊 "Time:2013-11-11 10:54.41\r\nPoint\tZ\t\r\n{X=-147, Y=0}\t1660.9\t\r\n{X=-141.12, Y=0}\t1660.9\t\r\n{X=-135.24, Y=0}\t1660.9\t\r\n"对这个字符串 希望匹配后能变成
    "Time:2013-11-11 10:54.41
    Point Z
    '{X=-147, Y=0} '1660.9
    '{X=-141.12, Y=0} '1660.9
    '{X=-135.24, Y=0} '1660.9"
    string result = Regex.Replace("内容", @"{.*?,[^}]+?}", "'$0'");
      

  5.   

    不符合啊 "Time:2013-11-11 10:54.41\r\nPoint\tZ\t\r\n{X=-147, Y=0}\t1660.9\t\r\n{X=-141.12, Y=0}\t1660.9\t\r\n{X=-135.24, Y=0}\t1660.9\t\r\n"对这个字符串 希望匹配后能变成
    "Time:2013-11-11 10:54.41
    Point Z
    '{X=-147, Y=0} '1660.9
    '{X=-141.12, Y=0} '1660.9
    '{X=-135.24, Y=0} '1660.9"
    string result = Regex.Replace("内容", @"{.*?,[^}]+?}", "'$0'");如果原数据没有{和}呢?
      

  6.   

    不符合啊 "Time:2013-11-11 10:54.41\r\nPoint\tZ\t\r\n{X=-147, Y=0}\t1660.9\t\r\n{X=-141.12, Y=0}\t1660.9\t\r\n{X=-135.24, Y=0}\t1660.9\t\r\n"对这个字符串 希望匹配后能变成
    "Time:2013-11-11 10:54.41
    Point Z
    '{X=-147, Y=0} '1660.9
    '{X=-141.12, Y=0} '1660.9
    '{X=-135.24, Y=0} '1660.9"
    string result = Regex.Replace("内容", @"{.*?,[^}]+?}", "'$0'");如果原数据没有{和}呢?
    string result = Regex.Replace("内容", @"\S+,[ ]\S+", "'$0'");