我想把第一个TABLE和table里的内容都替换成空,如何来写。 代码在下面
第一个TABLE
<table id="EspeciallyPro1_dtList" ....(样式)>....(内容)<table>
第二个TABLE
<table>....(内容)<table>现在我想找出第一个TABLE ,然后把TABLE和TABLE内容替换成空。谢谢

解决方案 »

  1.   

    s = Regex.Replace(s, @"<table\s+id.*?</table>", "");
      

  2.   


    <table id="EspeciallyPro1_dtList" [\s|\S]*?<table>使用正则匹配到被替换的内容,在用替换的table替换即可
      

  3.   


    <table id="EspeciallyPro1_dtList" [\s|\S]*?</table>少了/
      

  4.   

    try...Regex reg = new Regex(@"(?is)<table\s+id=""EspeciallyPro1_dtList""[^>]*>(?><table[^>]*>(?<o>)|</table>(?<-o>)|(?:(?!</?table\b).)*)*(?(o)(?!))</table>");
    string result = reg.Replace(yourStr, "");
      

  5.   

    <div id="divAnNiu" style="WIDTH:100%; TEXT-ALIGN:right">
    <asp:LinkButton ID="hlkShopping" Runat="server">
    <img src="images/truelab_index_09.gif"></asp:LinkButton>
    <asp:LinkButton ID="hlkCollection" Runat="server">
    <img src="images/viewDetail.gif" height="21" width="46"></asp:LinkButton>
    <asp:LinkButton ID="hlkPrice" Runat="server">
    <img src="images/askPrice.gif" height="21" width="46"></asp:LinkButton>
    </div>把这个DIV和DIV里的内容都替换成空怎么写
      

  6.   

    s = Regex.Replace(s, @"(?si)<div\b.*?</div>", "");
      

  7.   

    你这个不能把我所有的DIV都替换成空了吧
      

  8.   

    string str=@"\<div.\<\/div\>";
    regex r=new regex(str);
    match m=r.match("你的内容");
    string unit=m.value.tostring();
    //然后你可以replace掉,如果存在多个的话,就用matchcollection
      

  9.   

    你们给的都是替换我所有的DIV了, 我就要替换<div id="divAnNiu" style="WIDTH:100%; TEXT-ALIGN:right"> <DIV> 的, 我页面DIV  好几十个,一替换,页面啥都没有了,  谁给详细的,谢谢