Are you sure this will not spuriously match e.g. `window.onload = function () { `? And how do you strip off trailing junk?