The matching rule cannot be used for "/."
Source code Example:
Copy the Code code as follows:
Header ("Content-type:text/html;charset=utf-8");
$str = '
Test PHP regular match out JS code test PHP regular match out JS code test PHP regular match out JS code test PHP regular match out JS code test PHP regular match out JS code test PHP regular match out JS code
Test PHP regular match the JS Code ';
$preg = "/ <> /I <\ script="">";
$newstr = Preg_replace ($preg, "", $str, 3); The fourth parameter, 3, replaces 3 times, the default is-1, replaces all
Echo $newstr;<\>
?>
http://www.bkjia.com/PHPjc/768139.html www.bkjia.com true http://www.bkjia.com/PHPjc/768139.html techarticle matching rules can not be used "/script.*\/script/i", because it does not match to the newline character, then the multi-line JS will not be matched off. To use "/script[\s\s]*?\/script/i". The inside? means as little as possible ...