eg:
str=传过来的代码
str=str.replace(/<script .*>.*<\/script>/)
aert(str)

解决方案 »

  1.   

    $fp = fopen("1.html","r");
    $buffer = fread($fp,filesize("1.html"));
    $pattern ="'<script(.*?)?>(.*?)<\/script>'si";
    function replaceHtml($matches){
    $text = $matches[0];
    return htmlspecialchars($text);
    }
    $newText = preg_replace_callback($pattern,"replaceHtml",$buffer);
    fclose($fp);上面的例子将所有的javascript代码替换成html,你试试,$newText就是你的结果
      

  2.   

    啊!我的程序要修改,少了个参数!SORRY:)
    eg:
    str=传过来的代码
    str=str.replace(/<script .*>/ig;"#script#")
    str=str.replace(/<\/script>/ig;"#/script#")
    alert(str)另外:这是在客户端替换,替换完了你再保存入数据库好了