Home > Article > Backend Development > 正则婚配嵌套div ,求PHP实现
正则匹配嵌套div ,求PHP实现~
如下html串:
$str = '
<?php<br /> $str = '<div class="am1"><br /> <div class="image">1111111111</div><br /> <div class="image">2222222222</div><br /> <a href="test.php">link1</a><br /> </div><br /> <div class="am1"><br /> <div class="image">1111111111</div><br /> <img src="./tt.gif" / alt=" 正则婚配嵌套div ,求PHP实现 " ><br /> <div class="image">2222222222</div><br /> </div>';<br /> if (preg_match_all('#<div[^>]*>((?>[^</div>]+<br><font color='#FF8000'>------解决方案--------------------</font><br><a.+?>.+?</a><br><font color='#FF8000'>------解决方案--------------------</font><br><img .+?/ alt=" 正则婚配嵌套div ,求PHP实现 " ><br><font color='#FF8000'>------解决方案--------------------</font><br>(?R))*)</div>#is', $str, $matches)){<br /> print_r($matches);<br /> }<br /> ?>