本帖最后由 xianzhi22 于 2011-03-12 12:07:01 编辑

解决方案 »

  1.   

    Regex reg = new Regex(@"(?is)<div[^>]*?id=(['""\s]?)content\1[^>]*?>(?<content>((?!</?div).)*)");
    MatchCollection mc= reg.Matches(str);
     for (int i = 0; i < mc.Count; i++)
            {
                Response.Write(mc[i].Value);
            }
      

  2.   

        string str = "<div class=\"TitleBox marginTop10\">"
            + "<div class=\"title_left\"></div>"
            + "<div class=\"title_center\">"
            + "<div class=\"title_bk_left\"></div>"
      + " <div class=\"title_bk_center\" id=\"content\">奇石大全</div>"
       + "  <div class=\"title_bk_rigth\"></div> "
       + "    </div>"
       + " </div>";
                Regex reg = new Regex(@"(?is)<div[^>]*?id=(['""\s]?)content\1[^>]*?>(?<content>((?!</?div).)*)");
                MatchCollection match = reg.Matches(str);
                foreach (Match m in match)
                {
                    Response.Write(m.Groups["content"].Value + "<br/>");
                }
    可否在DIV中加一个id   + " <div class=\"title_bk_center\" id=\"content\">奇石大全</div>"
      

  3.   

    这样貌似可以获得指定ID的DIV标签里面的匹配标签,但要是一个页面多个模板标签,而且嵌套的DIV结构也是不一样的,好像就不行了