我想用MatchCollection分别取出来区域1和区域2的文字,应该怎么写啊?比如:………………上边的HTML代码………… 
<div class=brs_col>区域1</div>
<div class=brs_col>区域2</div>
………………下边的代码………………

解决方案 »

  1.   

    Regex re = new Regex(@">(.*?)</div>",RegexOptions.None); 
    MatchCollectionre.Matches mc = new MatchCollectionre.Matches("Text");
    foreach (Match mc in mc) //搜索所有父匹配
    {
        MessageBox.Show(mc.Value);
        foreach (Match mc1 in mc.Groups) //搜索所有子匹配
        {
            MessageBox.Show(mc1.Value);
        }
    {
      

  2.   

    Regex reg = new Regex(@"(?is)<div\sclass=brs_col[^>]*>(.*?)</div>");
    Match m = reg.Match("");
    if (m.Success)
    {
      TextBox1.Text = m.Value+"<br>";
    }
      

  3.   

    try...            Regex reg = new Regex(@"(?is)<div[^>]*?class=(['""]?)brs_col\1[^>]*>(.*?)</div>");
                MatchCollection mc = reg.Matches(yourStr);
                foreach(Match m in mc)
                {
                    richTextBox2.Text += m.Groups[2].Value + "\n";
                }
      

  4.   

    很好用,谢谢了。
    顺便问一下,
    1、取得超链接地址,如果<a href="http://www.baidu.com">fsd</a>,只要http://www.baidu.com
    2、去掉<b>aaa</b>标签,只要aaa字符串的正则是神马?
      

  5.   


    MatchCollection mc = Regex.Matches(Text, @"(?is)(?<=<div[^>]*?>).*?(?=</div>)");
    foreach (Match m in mc)
    {
        Console.WriteLine(m);
    }