Im trying to take a javascript out from some code but I can't get the right regex to match the code, another problem is that I just cant take out all <script tags because I want all the other ones to work correctly.
I tried
<?
$_response = '
before
<script type="text/javascript">
<!--
var ctl00_Main_postComment_rqfValidator = document.all ? document.all["ctl00_Main_postComment_rqfValidator"] : document.getElementById("ctl00_Main_postComment_rqfValidator");
ctl00_Main_postComment_rqfValidator.controltovalidate = "ctl00_Main_postComment_commentTextBox";
ctl00_Main_postComment_rqfValidator.errormessage = "Error: You can\'t enter a blank comment.";
ctl00_Main_postComment_rqfValidator.validationGroup = "ValGroup";
ctl00_Main_postComment_rqfValidator.evaluationfunction = "RequiredFieldValidatorEvaluateIsValid";
ctl00_Main_postComment_rqfValidator.initialvalue = "";
// -->
</script>
after';
$_response = preg_replace('/<script type="text\/javascript">\n<!--\nvar ctl00_Main_postComment_rqfValidator(.*?)\/\/ -->\n<\/script>/i', 'javascript cleared' , $_response);
echo $_response;
?>
But it seams the preg_replace doesn't match that expression. How could I make it match "<script type="text/javascript"><!--var ctl00_Main_postComment_rqfValidator" until "</script>" but not take all other javascript off the page?
Thanks for any help