This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
Problem with the "foreach" on the list of attributes is that content needs to be parsed as many times as there are attributes to look for, whereas it could be parsed only once. Two ways to improve current loop: 1. use the possibility provided by preg_replace to take an array of patterns as argument and fill $patterns with all the possibility before issuing one and only call to preg_replace. I am not sure how preg_replace is optimized internally though. The result may be the same, and that sure isn't that optimized. 2. use the foreach loop to generate a pattern list of the form: on(load|unload|click|dblclick|mousedown|...) ... and then have $patterns contain the 3 possible combinations of the resulting pattern.
Changing bug's title, I had fixed the regexp problem.