国产探花免费观看_亚洲丰满少妇自慰呻吟_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(
 
?
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 富顺县| 湟中县| 黎城县| 大关县| 沈丘县| 安义县| 泉州市| 辽宁省| 遂宁市| 泰宁县| 十堰市| 明光市| 五河县| 阳新县| 登封市| 余江县| 霞浦县| 乌审旗| 溆浦县| 玉溪市| 铁力市| 江达县| 黄山市| 施甸县| 定兴县| 通许县| 从江县| 桐城市| 吉木萨尔县| 东光县| 蕉岭县| 乌拉特中旗| 湖州市| 含山县| 扎赉特旗| 沁源县| 建昌县| 五莲县| 普格县| 南宁市| 金山区|