字符串格式如下:
"ABC",10,100,"DEF",5,50,"GHI",5,50现需要将匹配到这种格式的字符串时,将九个变量提取出来进行分析。很急,请大家帮忙,非常感谢!!!

解决方案 »

  1.   


    Regex re = new Regex("[^,]+");
    MatchCollection mc = re.Matches(input);
    foreach(Match m in mc)
    {
        Console.WriteLine(m.Value);
    }
      

  2.   

    引号里面可能是任何东西,数字,字母或者特殊符号这是我写的,系统报错了string CmdPattern = @"^\""(?<S1>*)\"",(?<S1U>\d+),(?<S1T>\d+)*";
    Regex CmdExpression = new Regex(CmdPattern, RegexOptions.Compiled);
      

  3.   

    这样啊
    string CmdPattern = "(?<S1>\"[^\"]+\"),(?<S2U>\\d+),(?<S1T>\\d+)"
      

  4.   


    提示 正在分析“(? <S1>"[^"]+"),(? <S1U>\d+),(? <S1T>\d+)”- 无法识别的分组构造。
      

  5.   


    string CmdPattern = "(?<S1>\"[^\"]+\"),(?<S2U>\\d+),(?<S1T>\\d+)" // 注意没有空格
      

  6.   


                string str = "\"ABC\",10,100,\"DEF\",5,50,\"GHI\",5,50";
                Regex re = new Regex("(?<S1>\"[^\"]+\"),(?<S2U>\\d+),(?<S1T>\\d+)");
                Match m = re.Match(str);
                while (m.Success)
                {
                    string output = m.Groups[1].Value + " " + m.Groups[2].Value + " " + m.Groups[3].Value + " ";
                    Console.WriteLine(output);
                    m = m.NextMatch();
                }//我这里得着呢
      

  7.   

    "(?:^|,)(?:\"(?<value1>(?:[^\"]+|\"\")*)\"|(?<value2>[^\",]*))"
      

  8.   


    @"""(?<s1>[^""]*)"",(?<s1u>\d*),(?<s1t>\d*)"
    //借用楼主的分组名