国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

php過濾HTML標簽、屬性等正則表達式匯總

2024-05-04 23:25:50
字體:
來源:轉載
供稿:網友
這篇文章主要介紹了php過濾HTML標簽、屬性等正則表達式匯總,本文使用代碼實例給出了過濾HTML內容的正則表達式,具體說明請參閱代碼中的注釋,本文對使用PHP做采集的朋友有比較大的作用,需要的朋友可以參考下
$str=preg_replace("//s+/", " ", $str); //過濾多余回車
$str=preg_replace("/<[ ]+/si","<",$str); //過濾<__("<"號后面帶空格)
 
$str=preg_replace("/</!--.*?-->/si","",$str); //注釋
$str=preg_replace("/<(/!.*?)>/si","",$str); //過濾DOCTYPE
$str=preg_replace("/<(//?html.*?)>/si","",$str); //過濾html標簽
$str=preg_replace("/<(//?head.*?)>/si","",$str); //過濾head標簽
$str=preg_replace("/<(//?meta.*?)>/si","",$str); //過濾meta標簽
$str=preg_replace("/<(//?body.*?)>/si","",$str); //過濾body標簽
$str=preg_replace("/<(//?link.*?)>/si","",$str); //過濾link標簽
$str=preg_replace("/<(//?form.*?)>/si","",$str); //過濾form標簽
$str=preg_replace("/cookie/si","COOKIE",$str); //過濾COOKIE標簽
 
$str=preg_replace("/<(applet.*?)>(.*?)<(//applet.*?)>/si","",$str); //過濾applet標簽
$str=preg_replace("/<(//?applet.*?)>/si","",$str); //過濾applet標簽
 
$str=preg_replace("/<(style.*?)>(.*?)<(//style.*?)>/si","",$str); //過濾style標簽
$str=preg_replace("/<(//?style.*?)>/si","",$str); //過濾style標簽
 
$str=preg_replace("/<(title.*?)>(.*?)<(//title.*?)>/si","",$str); //過濾title標簽
$str=preg_replace("/<(//?title.*?)>/si","",$str); //過濾title標簽
 
$str=preg_replace("/<(object.*?)>(.*?)<(//object.*?)>/si","",$str); //過濾object標簽
$str=preg_replace("/<(//?objec.*?)>/si","",$str); //過濾object標簽
 
$str=preg_replace("/<(noframes.*?)>(.*?)<(//noframes.*?)>/si","",$str); //過濾noframes標簽
$str=preg_replace("/<(//?noframes.*?)>/si","",$str); //過濾noframes標簽
 
$str=preg_replace("/<(i?frame.*?)>(.*?)<(//i?frame.*?)>/si","",$str); //過濾frame標簽
$str=preg_replace("/<(//?i?frame.*?)>/si","",$str); //過濾frame標簽
 
$str=preg_replace("/<(script.*?)>(.*?)<(//script.*?)>/si","",$str); //過濾script標簽
$str=preg_replace("/<(//?script.*?)>/si","",$str); //過濾script標簽
$str=preg_replace("/javascript/si","Javascript",$str); //過濾script標簽
$str=preg_replace("/vbscript/si","Vbscript",$str); //過濾script標簽
$str=preg_replace("/on([a-z]+)/s*=/si","On//1=",$str); //過濾script標簽
$str=preg_replace("/&#/si","&#",$str); //過濾script標簽,如javAsCript:alert(
 
?
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 苏尼特左旗| 莱州市| 肇庆市| 铁岭县| 青龙| 仙桃市| 莎车县| 顺昌县| 尚志市| 大渡口区| 尖扎县| 林芝县| 鄄城县| 南靖县| 临漳县| 乐山市| 富裕县| 丹江口市| 灵川县| 莫力| 武安市| 祁门县| 吴旗县| 康保县| 四平市| 乌拉特后旗| 永善县| 会宁县| 长宁区| 肥东县| 皋兰县| 仪征市| 齐齐哈尔市| 光泽县| 永川市| 安多县| 萨迦县| 潢川县| 高陵县| 邹平县| 桐梓县|