refreezed;1244695 wrote:Happy new year Padonak!
I changed your RegExp a bit so it would match more variations of script tags:
/<\s*script.*?>.*?(<\s*\/script.*?>|$)/ig
Though, I would choose rnd's solution over using regular expressions - it seems to the most secure way.
thanks man, but this regexp matches tags only and ignores everything between these tags. i do not need to remove or disable the script tags only, i am trying to find the way to cut off the script tags and all the code between them by replacing it with nothing
data=data.replace(regexp goes here,'nothing');
for example, let us try to remove all scripts from this code:
<meta http-equiv="content-type" content="text/html; charset=windows-1251">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
<script type="text/javascript" src="/scripts/jquery-1.4.2.min_223.js"></script>
<script type="text/javascript" src="/scripts/overlib.js"></script>
<script type="text/javascript" src="/scripts/ressources.js"></script>
<script type="text/javascript" src="/scripts/form.js"></script>
</head>
<body>
<script type="text/javascript" language="javascript">
var ress = new Array(2647618, 174070, 442978);
var max = new Array(5525950,3069400,1709800);
var production = new Array(32.011111111111, 10.041666666667, 5.6625);
window.setInterval("res_online()",1000);
</script>
<form name="ress" id="ress" style="display:inline">
<INPUT TYPE="hidden" ID="metall" value="0">
<INPUT TYPE="hidden" ID="crystall" value="0">
<INPUT TYPE="hidden" ID="deuterium" value="0">
<INPUT TYPE="hidden" ID="bmetall" value="0">
<INPUT TYPE="hidden" ID="bcrystall" value="0">
<INPUT TYPE="hidden" ID="bdeuterium" value="0">
</form>
this is a fragment of the response data. before i put it in a temp div i need this code to become "script-free", smth like this:
<meta http-equiv="content-type" content="text/html; charset=windows-1251">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
</head>
<body>
<form name="ress" id="ress" style="display:inline">
<INPUT TYPE="hidden" ID="metall" value="0">
<INPUT TYPE="hidden" ID="crystall" value="0">
<INPUT TYPE="hidden" ID="deuterium" value="0">
<INPUT TYPE="hidden" ID="bmetall" value="0">
<INPUT TYPE="hidden" ID="bcrystall" value="0">
<INPUT TYPE="hidden" ID="bdeuterium" value="0">
</form>