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);
精彩评论