本帖最后由 roha 于 2010-02-09 17:32:29 编辑

解决方案 »

  1.   

    echo preg_replace('@(<a href=\"/ns\?word=(.*))条相同新闻(&gt;&gt;</a></font>)@','$1$3',$html);//把正则中的空间去掉, csdn自己加上去的
      

  2.   

    补充, preg_replace的第三个参数是你自己的字符串
      

  3.   

    那个标签就有问题的 <a> 和 <font> 标签用反了
    $str = <<<str
    <table cellspacing=0 cellpadding=2> 
    <tr> 
    <td class="text"> <a href="http://news.china.com.cn/rollnews/2010-02/09/content_536553.htm "  mon="a=5&pn=6" target=_blank> <span> <b>美国对中国 <font color="#C60A00">礼盒 </font>征 <font color="#C60A00">反倾销 </font>税 </b> </span> </a> <font color=#6f6f6f> <nobr>中国网 2010-2-9 09:40 </nobr> </font> <br> <font size=-1>美国对中国 <font color="#C60A00">礼盒 </font>征 <font color="#C60A00">反倾销 </font>税  据《第一财经日报》  就在中国商务部公布对美白羽肉鸡产品 <font color="#C60A00">反倾销 </font>调查初步裁决之际,美国再度挑起贸易战,对中国产礼物盒以及包装 <font color="#C60A00">丝带 </font>征收高额 <font color="#C60A00">反倾销 </font>税。  美国商务部上周五决定,对中国大陆产的礼物盒以及包装 <font color="#C60A00">丝带 </font>,征收最高超过231%的 <font color="#C60A00">反倾销 </font>税,... </font>    </td> </tr> </table> <br> 
    <table cellspacing=0 cellpadding=2> 
    <tr> 
    <td class="text"> <a href="http://www.cnstock.com/index/gdbb/201002/379952.htm "  mon="a=5&pn=7" target=_blank> <span> <b>午评:5日均线压力沉重 沪指上攻再遇阻 </b> </span> </a> <font color=#6f6f6f> <nobr>中国证券网 2010-2-9 11:44 </nobr> </font> <br> <font size=-1>美国方面则掐准时间,随即表示对中国内地产的礼物盒以及包装 <font color="#C60A00">丝带 </font>征收最高超过231%的 <font color="#C60A00">反倾销 </font>税。消息一出,...业内人士表示,我国 <font color="#C60A00">礼盒 </font>及 <font color="#C60A00">丝带 </font>的生产地主要是东南沿海,而台湾的大部分生产商也已经搬到内地。一旦征收如此之高的 <font color="#C60A00">反倾销 </font>税,大部分国内出口企业将完全放弃美国市场。  ... </font>    
    <a href="/ns?word=%C0%F1%BA%D0+%CB%BF%B4%F8+%B7%B4%C7%E3%CF%FA+cont:1282492241&cl=1&tn=news&rn=30 "><font color=#008000>3条相同新闻&gt;&gt;</a></font> 
    </td> </tr> </table> <br> 
    <table cellspacing=0 cellpadding=2> 
    <tr> <td class="thumbnail"> 
    <a class=r href="http://finance.ifeng.com/news/industry/20100209/1816517.shtml " target=_blank mon="a=4"> <img src="/ni?u=http://img.ifeng.com/tres/finance/upload/images/2010/0209/142739/33_1816517_2db4e5ad03bc35af792214efe1cd00b3.jpg " border=1> </a> 
    </td> 
    <td class="text"> <a href="http://finance.ifeng.com/news/industry/20100209/1816517.shtml "  mon="a=5&pn=8" target=_blank> <span> <b>中美贸易摩擦拳脚越打越快 广东 <font color="#C60A00">丝带 </font>出口受创 </b> </span> </a> <font color=#6f6f6f> <nobr>凤凰网 2010-2-9 14:27 </nobr> </font> <br> <font size=-1>虽然美国此次对中国 <font color="#C60A00">礼盒 </font> <font color="#C60A00">丝带 </font> <font color="#C60A00">反倾销 </font>涉案金额不高,但选择在中国对美肉鸡案初裁第二天公布,分析普遍认为其“反制”意味明显。自从去年轮胎案以来,中美之间不仅贸易摩擦不断,... </font>    
    <a href="/ns?word=%C0%F1%BA%D0+%CB%BF%B4%F8+%B7%B4%C7%E3%CF%FA+cont:2403721963&cl=1&tn=news&rn=30 "><font color=#008000>5条相同新闻&gt;&gt;</a></font> 
    </td> </tr> </table> <br> 
    <table cellspacing=0 cellpadding=2> 
    <tr> 
    <td class="text"> <a href="http://nf.nfdaily.cn/21cbh/content/2010-02/09/content_9095438.htm "  mon="a=5&pn=9" target=_blank> <span> <b>美对华 <font color="#C60A00">礼盒 </font> <font color="#C60A00">丝带 </font>征收 <font color="#C60A00">反倾销 </font>税 贸易摩擦升级 </b> </span> </a> <font color=#6f6f6f> <nobr>南方报业网 2010-2-9 08:18 </nobr> </font> <br> <font size=-1>对中国大陆包装 <font color="#C60A00">丝带 </font>征收 <font color="#C60A00">反倾销 </font>税远高于台湾,并没有道理。  另外据相关人士分析,美国此举一旦付诸实施,中国大陆的礼物盒以及包装 <font color="#C60A00">丝带 </font>可能退出美国市场,但对美国人也没有好处。该相关人士指出,美国企业普遍是到中国进行订单采购礼物盒以及包装 <font color="#C60A00">丝带 </font>,常用于情人节等节日礼品的包装,... </font>    </td> </tr> </table> <br>
    str;echo $str;
    echo '<hr>';$str = preg_replace('/\<a.*相同新闻.*\<\/font\>/Ui', '', $str);echo $str;
      

  4.   

    4楼那么细心, 我都没看他html,  直接正则配上收工 ...
      

  5.   

    eregi_replace(" <a href=\"/ns\?word=(.*?)条相同新闻&gt;&gt; </a> </font>",'',$str); 用非贪婪匹配就行了