I apologise as I have very little knowledge about Regex and I don\'t even understand exactly what this regex is doing (I didn\'t write it - source) apart from the fact it se
You mentioned in a comment that it would be acceptable to remove script tags before performing the search.
$data = preg_replace('/<\s*script.*?\/script\s*>/iu', '', $data);
This code may help with that.