本帖最后由 wpost 于 2010-03-18 22:19:16 编辑

解决方案 »

  1.   

    <?php 
    $str='<div style="background:#EFF2FA;overflow:hidden;padding:0 3px;line-height:29px;height:30px;word-break:normal;">adfadfadfadfadfadad</div>';
    echo preg_replace("/\<div.+?\>(.*?)\<\/div\>/","123456",$str);
    ?>
      

  2.   

    <?php 
    $str='<div style="background:#EFF2FA;overflow:hidden;padding:0 3px;line-height:29px;height:30px;word-break:normal;">adfadfadfadfadfadad</div>';
    echo htmlspecialchars(preg_replace("/(\<div.+?\>)(.*?)(\<\/div\>)/","\${1}123456\${3}",$str));//<div style="background:#EFF2FA;overflow:hidden;padding:0 3px;line-height:29px;height:30px;word-break:normal;">123456</div>
    ?>
      

  3.   

    楼上的先谢谢了。不过我的意思是
    前面 后面有好多的DIV 但是就这个
    <div style="background:#EFF2FA;overflow:hidden;padding:0 3px;line-height:29px;height:30px;word-break:normal;">
    是一个唯一 ,这个该如何写正则?