字符串的格式为如下:
.00(2),7.00(1),8.00(4),
现在想把字符串拆分成如下格式:
.00,.00,7.00,8.00,8.00,8.00,8.00
意思是:如果括号里面的数为2,就把括号前的字符写两份,用,分隔
多谢

解决方案 »

  1.   


    string str = ".00(2),7.00(1),8.00(4),";
              str = Regex.Replace(str, @"(\d*?\.\d+)\((\d+)\)(?=[,,]|$)", delegate(Match m)
                {
                    string source = "";
                    int n = Convert.ToInt32(m.Groups[2].Value);
                    for (int i = 0; i < n; i++)
                        source += m.Groups[1].Value + (i < n - 1 ? "," : "");
                    return source;            });
      

  2.   

    额。。这好像是C#的语法吧。。有SQL的么?