I am trying to remove JavaScript from the HTML.
I can\'t get the regular expression to work with PHP; it\'s giving me an null array. Why?
In your case you could regard the string as a list of newline delimited strings and remove the lines containing the script tags(first & second to last) and you wouldn't even need regular expressions.
Though if what you are trying to do is preventing XSS it might not be sufficient to only remove script tags.