$ptn="/<tr +bgcolor=\"#ffffff\">.*?<\/tr>/is";
$str=preg_replace($ptn,"",$str);

解决方案 »

  1.   


    $ptn="/<tr +bgcolor=\"#ffffff\">[\s\S]*<\/tr>/is";
    $str=preg_replace($ptn,"",$str);试试呢?
    好像"."不匹配回车什么的
      

  2.   

    $search = "/<tr(.*?)<iframe (.*?)<\/tr>/is";
    preg_replace($search,'------------',$str);
      

  3.   

    $search = "/<tr(.*?)<iframe (.*?)<\/tr>/is";
    $y =  preg_replace($search,'',$str);
      

  4.   

    <?php
    $str = '<html>
    <head/>
    <body>
    <table   width="520"   cellspacing="1"   cellpadding="5"   border="0"   bgcolor="#cccccc"   align="center"   bordercolordark="#ffffff">
    <tbody>
    <tr   bgcolor="#e9f8d7">
    <td   align="center"   colspan="4"> 身份证号码查询解读、验证和升级结果 </td>
    </tr>
    <tr   bgcolor="#ffffff">
    <td   colspan="4">
    <script   type="text/javascript">
    </script>
    <script   src="http://images.sohu.com/cs/jsfile/js/cpc.js"   type="text/javascript"   language="JavaScript">
    </script>
    <iframe   width="468"   scrolling="no"   height="42"   frameborder="0"   src="http://sogou.com/cpc_ads?pid=123cha&fmt=h_468_60&iw=468&ih=42&charset=gb2312&c_bo=FFFFFF&c_bg=FFFFFF&c_li=0055E5&c_te=000000&c_bt=000000&c_hl=FF0900&sv=0&sl=1&hl=0&tnt=0&sohuurl=http://localhost/index_test.php"   allowtransparency="true"   marginheight="0"   marginwidth="0">
    </iframe>
    </td>
    </tr>
    <tr>
    <td   width="120"   bgcolor="#f6f6f6"   align="center"> 出生日期 </td>
    <td   width="240"   bgcolor="#ffffff"   align="center"> 1982   年   02   月   13   日 </td>
    <td   width="80"   bgcolor="#f6f6f6"   align="center"> 性别 </td>
    <td   width="80"   bgcolor="#ffffff"   align="center"> 男 </td>
    </tr>
    <tr>
    </tr>
    <tr>
    </tr>
    <tr>
    </tr>
    <tr>
    </tr>
    <tr>
    </tr>
    <tr   height="28">
    </tr>
    </tbody>
    </table>
    </body>
    </html> ';
    $search = "/<tr(.*?)<iframe (.*?)<\/tr>/is";
    $result =  preg_replace($search,'',$str);
    echo htmlspecialchars($result);?>
      

  5.   

    <?php
    $handle = fopen("http://www.123cha.com/idcard/352601198202134013/", "rb");
    $contents = stream_get_contents($handle);$contents = eregi_replace(".*<table id=\"tb\"", "<table", $contents);
    $contents = eregi_replace("</table>.*", "", $contents);
    //$contents = eregi_replace("<tr +bgcolor=\"#ffffff\">(.*?)<\/iframe><\/td><\/tr>", "", $contents);
    //$ptn = "/<tr +bgcolor=\"#ffffff\">(.*?)<\/iframe><\/td><\/tr>/is";
    //$contents=preg_replace($ptn,"",$contents);
    echo $contents;
    ?>
    可能是我没说清楚,不好意思,我会适当加分
    代码如上,我要去掉那个广告