I am looking for a Regular expression in PHP that removes all style attributes from "p" and "span" tags but leave style attributes from "td" and so on untouched.
I have this now: (this finds all style="..." stuff)
$pattern = '[style=("[^"]*")]';
$content = '<td style="blabla">
<p style="blabla">
text <span style=blabla">more text</span>
</p>
</td>';
To be used in preg_replace()
$newcontent = preg_replace($pattern, '', $content);
But this removes the style in the td too and I don't want that.
So in the end after replacement I want to have
<td style="blabla">
<p>text <span>more text</span>
</p>
</td>