收集php利用正则过滤各种标签,空格,换行符的代码:
01 |
$str=preg_replace("/\s+/", " ", $str); |
02 |
$str=preg_replace("/<[ ]+/si","<",$str); |
03 |
$str=preg_replace("/<\!–.*?–>/si","",$str); |
04 |
$str=preg_replace("/<(\!.*?)>/si","",$str); |
05 |
$str=preg_replace("/<(\/?html.*?)>/si","",$str); |
06 |
$str=preg_replace("/<(\/?head.*?)>/si","",$str); |
07 |
$str=preg_replace("/<(\/?meta.*?)>/si","",$str); |
08 |
$str=preg_replace("/<(\/?body.*?)>/si","",$str); |
09 |
$str=preg_replace("/<(\/?link.*?)>/si","",$str); |
10 |
$str=preg_replace("/<(\/?form.*?)>/si","",$str); |
11 |
$str=preg_replace("/cookie/si","COOKIE",$str); |
12 |
$str=preg_replace("/<(applet.*?)>(.*?)<(\/applet.*?)>/si","",$str); |
13 |
$str=preg_replace("/<(\/?applet.*?)>/si","",$str); |
14 |
$str=preg_replace("/<(style.*?)>(.*?)<(\/style.*?)>/si","",$str); |
15 |
$str=preg_replace("/<(\/?style.*?)>/si","",$str); |
16 |
$str=preg_replace("/<(title.*?)>(.*?)<(\/title.*?)>/si","",$str); |
17 |
$str=preg_replace("/<(\/?title.*?)>/si","",$str); |
18 |
$str=preg_replace("/<(object.*?)>(.*?)<(\/object.*?)>/si","",$str); |
19 |
$str=preg_replace("/<(\/?objec.*?)>/si","",$str); |
20 |
$str=preg_replace("/<(noframes.*?)>(.*?)<(\/noframes.*?)>/si","",$str); |
21 |
$str=preg_replace("/<(\/?noframes.*?)>/si","",$str); |
22 |
$str=preg_replace("/<(i?frame.*?)>(.*?)<(\/i?frame.*?)>/si","",$str); |
23 |
$str=preg_replace("/<(\/?i?frame.*?)>/si","",$str); |
24 |
$str=preg_replace("/<(script.*?)>(.*?)<(\/script.*?)>/si","",$str); |
25 |
$str=preg_replace("/<(\/?script.*?)>/si","",$str); |
26 |
$str=preg_replace("/javascript/si","Javascript",$str); |
27 |
$str=preg_replace("/vbscript/si","Vbscript",$str); |
28 |
$str=preg_replace("/on([a-z]+)\s*=/si","On\\1=",$str); |
29 |
$str=preg_replace("/&#/si","&#",$str); |