rt,要将一个网页源代码中<script></script>中间的内容替换成空格,该如何写啊??

解决方案 »

  1.   

    preg_replace('/<script>(.*)<\/script>/is', ' ', $string);
      

  2.   

    preg_replace("/(<script>)(.*)(<\/script>)/e", "'\\1'.' '.'\\3'", $html_body);
      

  3.   

    preg_replace("/(<script[^>]*?>)(.*)(<\/script>)/e", "'\\1'.' '.'\\3'", $html_body);
      

  4.   

    preg_replace('/<script>([.\s]*)<\/script>/is', ' ', $string);
      

  5.   

    preg_replace('/<script[^>]*>([.\s]*)<\/script>/is', ' ', $string);
      

  6.   


    另外,为什么不直接弄 <script> ,而是  (<script[^>]*?>)
      

  7.   

    preg_replace('/(?:<script[^>]*>)(.*?)(?:<\/script>)/is', ' ', $string);
      

  8.   

    你的script标签都肯定没有任何属性的吗?是的话可以直接用<script>
      

  9.   

    preg_replace('/<script.*>([\d\D])<\/script>/i','',$string);
      

  10.   


    前面的括号 ‘(’里的内容。
    $pattern = '/<script.*?>(.*?)<\/script>/i';
    $replacement =  "<script> </script>";
     
    $a = preg_replace($pattern, $replacement,$string);
      

  11.   

    其实script前面还要有\s*因为<  script>也是可以运行的。
    另外有人正则<script[^>]*?>这个问号多余了吧。
      

  12.   

    \\1是正则第1个括号里的内容,\\3是正则第3个括号的内容不直接弄 <script> ,而是 (<script[^>]*?>)是因为并不是所有的script开始标记都只有<script>。
    还有可能会有<script language='***'>或其他什么