I am just learing about RegEx so bear with me.
I tried just splitting on /<script>/ and /<\/script>/ but if I were to load the HTML code with that script I end up with it being split on the lines that have the split command itself instead of just the opening and closing script tags.
I changed it to /\b<script>\b/ and /\b\/script>\b/ but it doesn't match anything and everything in the textarea is included in the array produced.
Here is the code I have now. How can change this to get the result I want?
<html>
<head>
<title>Script Removal Script</title>
</head>
<body>
<form name="form">
<textarea name="htmlCode" cols="120" rows="25">Insert your HTML code here then click on the "Process" button to remove all scripts.</textarea><br />
<input type="button" value="Process" onclick="removeScript(form.htmlCode.value);" />
</form>
<script type="text/javascript">
function removeScript(code)
{ var fString = code;
var first = fString.split(/\b\Wscript\W\b/);
var second = fString.split(/\b\W\/script\W\b/);
alert("the first array has " + first.length + " entries. The second array has " + second.length + " entries.");
return form.htmlCode.value = second[0];
}
</script>
<script>
//something worthless
</script>
</body>
</html>

New Topic/Question
Reply



MultiQuote




|