我为strip <script> </ script>标签创建此表单,但此表单不起作用

i create this form for strip <script></script> tags but this form not working please any one modify this form to start working

<html>
<head>
<script language='javascript'>
  function alfa(s) {
    return s.replace(/<script>[^<\/script>]*<\/script>/g, "");
  }
</script>
</head>
<body>
<form>
<textarea name="txt" style="width: 300px; height: 150px"></textarea><br />
<input type="button" value="Remove script tags" onClick="txt.value=alfa (txt.value)">
</form>
</body>
</html>

Try this one

s.replace(/<script[ >][\s\S]*?<\/script>/g, "");

Your starting tag is not neccesarily <script>. The tag name can befollowed by a space and additional attributes.

Also you use the [] character class the wrong way.

return s.replace(/<script>[\s\S]*?<\/script>/g, "");

[\s\S] means "any character" (dot in Javascript doesn't match ), the question mark makes the * "lazy". Use [^ ] only for negation of single character. [^<\/script>] means "any character except <, /, s, c, r, i, p, t or >".