Use the preg_replace regular expression matching function in php to filter out js code in the webpage. The fourth parameter in preg_replace () indicates the number of replicas. the default value is-1, indicating that all replicas are replaced; if you only want to replace it twice, you can write it as pre... use the preg_replace regular expression matching function in php to filter out js code in the webpage. The fourth parameter in preg_replace () indicates the number of replicas. the default value is-1, indicating that all replicas are replaced; if you only want to replace it twice, you can write it as preg_replace ($ p1, $ p2, $ p3, 2 ).
The matched rule cannot be used "/ <\ script> /I ", because it cannot match the line break, so multiple lines of js won't match. To use "/ <\ script> /I ". Inside? Indicates that there are as few duplicates as possible, that is, matching the latest script. <\> <\>
Source code example:
Script test php regular expression matching js code