Regex Remove Images with style tag from Html

Posted by Mark Milford on Stack Overflow See other posts from Stack Overflow or by Mark Milford
Published on 2010-05-05T11:40:05Z Indexed on 2010/05/05 11:48 UTC
Read the original article Hit count: 209

Filed under:
|

Hi

I am new to Regex, however I decided it was the easiest route to what I needed to do. Basically I have a string (in PHP) which contains a whole load of HTML code... I want to remove any tags which have style=display:none...

so for example

<img src="" style="display:none" />

<img src="" style="width:11px;display: none" >

etc...

So far my Regex is:

<img.*style=.*display.*:.*none;.* >

But that seems to leave bits of html behind and also take the next element away when used in php with preg_replace.

© Stack Overflow or respective owner

Related posts about regex

Related posts about php