{$photos.GetTopList("5","1=1","","topten","0","aaa","bbb","","","","","","")}通过正则匹配出 5 ,1=1 这样的参数

解决方案 »

  1.   

    根据什么取,按前后的"判断就可以了,还是说一定要在{$photos.GetTopList(...)}中的?MatchCollection mc = Regex.Matches(str, @"(?<="")[^""]*(?="")");
    foreach (Match m in mc)
    {
        richTextBox2.Text += m.Value + "\n";
    }这个是按"取的,现在没测试环境,代码手写,楼主测下吧
      

  2.   

    写得比较烂
    (?<=\(")\d+(?=\")|(?<=")\w+=\w+(?=\")
      

  3.   

     楼上的这样的好像不行啊 ,你看看     string str="{$photos.GetTopList('5','1=1','','topten','0','aaa','bbb','','','','','','')}" ;
            string ss="";
            MatchCollection mc = Regex.Matches(str, @"(?<='')[^'']*(?='')");
            foreach (Match m in mc)
            {
                 ss+= m.Value + "\n";
            }
      

  4.   

    这个,字符串前加了@,双引号是要用""进行转义的,而单引号就不用了MatchCollection mc = Regex.Matches(str, @"(?<=')[^']*(?=')");
    foreach (Match m in mc)
    {
        richTextBox2.Text += m.Value + "\n";
    }