替换 script 代码部分注释//....(//开始到行尾) 为空
$str="<script> document.write(unescape(\"%3Cspan id='szgs_stat_icon_2'%3E%3C/span%3E%3Cscript src='http://www.szgswljg.gov.cn/sendMark?siteid=2&website=z.com' type='text/javascript'%3E%3C/script%3E\")); </script><script type=\"text/javascript\" src=\"http://z.com/a.js\"></script><!--[if IE 6]><script type=\"text/javascript\" src=\"http://z.com/pngfix.js\"></script><![endif]--><script src=\"http://z.com/jquery.uploadify.3.2.1.js\"></script><script>//true56546456function showTips(type,msg,d){//true存在文件,false不存在文件$('#'+type).parent().find('span').text(msg).removeClass('Validform_right').addClass('Validform_wrong');}//truedddddddddvar uploadFile=false,//true存在文件,false不存在文件dia,upToken='roS2qYSKuPqZB7rZmvfpZy';//true存在文件,false不存在文件</script><span style=\"display:None;\"><script type=\"text/javascript\">var _bdhmProtocol = ((\"https:\" == document.location.protocol) ? \" https://\" : \" http://\");document.write(unescape(\"%3Cscript src='\" + _bdhmProtocol + \"hm.baidu.com/h.js?28' type='text/javascript'%3E%3C/script%3E\"));</script></span>2222222222222";
$str=preg_replace('/(<script>[\s\S]*?)[^(http:|https:)]\/\/.*?\n([\S\s]*?<\/script>)/si','$1$2',$str);echo $str;
$s =<<< TXT<script> document.write(unescape(\"%3Cspan id='szgs_stat_icon_2'%3E%3C/span%3E%3Cscript src='http://www.szgswljg.gov.cn/sendMark?siteid=2&website=z.com' type='text/javascript'%3E%3C/script%3E\")); </script><script type=\"text/javascript\" src=\"http://z.com/a.js\"></script><!--[if IE 6]><script type=\"text/javascript\" src=\"http://z.com/pngfix.js\"></script><![endif]--><script src=\"http://z.com/jquery.uploadify.3.2.1.js\"></script><script>//true56546456function showTips(type,msg,d){//true存在文件,false不存在文件$('#'+type).parent().find('span').text(msg).removeClass('Validform_right').addClass('Validform_wrong');}//truedddddddddvar uploadFile=false,//true存在文件,false不存在文件dia,upToken='roS2qYSKuPqZB7rZmvfpZy';//true存在文件,false不存在文件</script><span style=\"display:None;\"><script type=\"text/javascript\">var _bdhmProtocol = ((\"https:\" == document.location.protocol) ? \" https://\" : \" http://\");document.write(unescape(\"%3Cscript src='\" + _bdhmProtocol + \"hm.baidu.com/h.js?28' type='text/javascript'%3E%3C/script%3E\"));</script></span>2222222222222TXT;echo preg_replace('#([^:])//.+#m', '$1', $s);
<script> document.write(unescape(\"%3Cspan id='szgs_stat_icon_2'%3E%3C/span%3E%3Cscript src='http://www.szgswljg.gov.cn/sendMark?siteid=2&website=z.com' type='text/javascript'%3E%3C/script%3E\")); </script><script type=\"text/javascript\" src=\"http://z.com/a.js\"></script><!--[if IE 6]><script type=\"text/javascript\" src=\"http://z.com/pngfix.js\"></script><![endif]--><script src=\"http://z.com/jquery.uploadify.3.2.1.js\"></script><script>function showTips(type,msg,d){$('#'+type).parent().find('span').text(msg).removeClass('Validform_right').addClass('Validform_wrong');}var uploadFile=false,dia,upToken='roS2qYSKuPqZB7rZmvfpZy';</script><span style=\"display:None;\"><script type=\"text/javascript\">var _bdhmProtocol = ((\"https:\" == document.location.protocol) ? \" https://\" : \" http://\");document.write(unescape(\"%3Cscript src='\" + _bdhmProtocol + \"hm.baidu.com/h.js?28' type='text/javascript'%3E%3C/script%3E\"));</script></span>2222222222222
GOOD 精辟