Removing most inline styles and properties with PHP

Posted by bakkelun on Stack Overflow See other posts from Stack Overflow or by bakkelun
Published on 2010-04-16T13:56:47Z Indexed on 2010/04/16 14:03 UTC
Read the original article Hit count: 175

Filed under:
|
|

This question is related to a similar case, namely http://stackoverflow.com/questions/2488950/removing-inline-styles-using-php

The solution there does not remove i.e: <font face="Tahoma" size="4">

But let's say I have a mixed bag of inline styles and properties, like this:

<ul style="padding: 5px; margin: 5px;">
    <li style="padding: 2px;"><div style="border:2px solid green;">Some text</div></li>
    <li style="padding: 2px;"><font face="arial,helvetica,sans-serif" size="2">Some text</font></li>
    <li style="padding: 2px;"><font face="arial,helvetica,sans-serif" size="2">Some text</font></li>  
</ul>

What regExp is needed to achieve this result?

<ul>
    <li><div>Some text</div></li>
    <li><font>Some text</font></li>
    <li><font>Some text</font></li>  
</ul>

Thanks for reading the question, any help is appreciated.

© Stack Overflow or respective owner

Related posts about php

Related posts about preg-replace