使用preg_replace </div>删除整个嵌套的<div>

时间:2013-10-15 13:55:08

标签: php preg-replace

我需要使用preg_replace删除整个。不幸的是,我不能在这里使用任何PHP Dom设施,因为它是我未编码的脚本的一部分

<div class="box" id="idxFeach" style="">
<h2 class="gr"><div hint="Refresh" onclick="xEvent.frameLoad('#popularBox','/viewFrame.php?'+Math.random()); return false;" class="icon iconRefresh"></div>Featured</h2>
<div class="boxC">
<iframe frameborder="no" align="middle" scrolling="no" src="/viewFrame.php?1381845110781" allowtransparency="true" marginheight="0" marginwidth="0" id="popularBox"></iframe>
<div class="loader" style="display: none;"></div>
</div>
</div>

我需要删除整个

<div class="box" id="idxFeach" style=""> .. </div>

非常感谢

1 个答案:

答案 0 :(得分:1)

preg_replace使用生成有限自动机的正则表达式引擎,因此无法搜索常规嵌套表达式。更多信息:

Can regular expressions be used to match nested patterns?