Id will start with something like this to cut scripts and comments:
$htmlblacklist[] = '@<script[^>]*?>.*?</script>@si'; //bye bye javascript $htmlblacklist[] = '@<![\s\S]*?--[ \t\n\r]*>@'; //goodbye comments //now apply blacklist $value = preg_replace($htmlblacklist, '', $value);
For inline events, you should use a DOMDocument as it understands HTML, while Regex takes off in the dark.
In fact, you can use DOMDocument for all this and not use Regex at all. Load the HTML into a DOMDocument object and iterate through the tree, deleting what you want.
source share