开发者

php preg_replace except

There are many paragraph in one test.

<div class="text">...</div>
<div class="content">...</div>
<div class="aa bb">...</div>
<div class="aa cc">...</div>
<div class="aa dd">...</div>
<div class="aa ee">...</div>
<div class="aa ff">...</div>
...// more type of class="aa .*"

I want remove all the div class="aa" but except div class="aa dd", how to do this job? Thanks.

$html = preg_replace('/<div(.*?)class="aa(.*?)">([\s\S]*?)<\/div>/', '', $html);
// this will remove all the div include class 'aa', but I need rem开发者_如何转开发ain class 'aa dd'


echo preg_replace('~<div class="aa (?!dd).+?">.+?</div>~', "", $html);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜