如何使用php正则去掉html属性

  介绍

如何使用php正则去掉html属性?针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。

php使用正则去掉html的方法:首先创建一个php示例文件,然后通过正则表达式”preg_replace (“/& lt; ([a-za-z] +)[^祝辞]*祝辞/?“& lt; \ \ 1在“,html美元);“过滤所有html标签的属性即可。

php过滤html标签,属性等正则表达式汇总

$ str=preg_replace (“/\ s +/?““str美元);//过滤多余回车   $ str=preg_replace (“/& lt; [] +/si",“& lt;“, str美元);//过滤& lt; __ (“& lt;“号后面带空格)      $ str=preg_replace (“/& lt; \ !——* ?——祝辞/si",““, str美元);//注释   $ str=preg_replace (“/& lt;(\ !。* ?)祝辞/si",““, str美元);//过滤DOCTYPE   $ str=preg_replace (“/& lt; (\/html。* ?)祝辞/si",““, str美元);//过滤html标签   $ str=preg_replace (“/& lt;(\/头。* ?)祝辞/si",““, str美元);//过滤头标签   $ str=preg_replace (“/& lt;(\/元。* ?)祝辞/si",““, str美元);//过滤元标签   $ str=preg_replace (“/& lt;(\/身体。* ?)祝辞/si",““, str美元);//过滤体标签   $ str=preg_replace (“/& lt;(\/链接。* ?)祝辞/si",““, str美元);//过滤链接标签   $ str=preg_replace (“/& lt;(\/形式。* ?)祝辞/si",““, str美元);//过滤形式标签   $ str=preg_replace(“/饼干/si",“COOKIE", str美元);//过滤饼标签      $ str=preg_replace (“/& lt; (applet。* ?)在(. * ?)& lt; (\/applet。* ?)祝辞/si",““, str美元);//过滤applet标签   $ str=preg_replace (“/& lt; (\/applet。* ?)祝辞/si",““, str美元);//过滤applet标签      $ str=preg_replace (“/& lt;(风格。* ?)在(. * ?)& lt;(\/风格。* ?)祝辞/si",““, str美元);//过滤风格标签   $ str=preg_replace (“/& lt;(\/风格。* ?)祝辞/si",““, str美元);//过滤风格标签      $ str=preg_replace (“/& lt;(标题。* ?)在(. * ?)& lt;(\/标题。* ?)祝辞/si",““, str美元);//过滤标题标签   $ str=preg_replace (“/& lt;(\/标题。* ?)祝辞/si",““, str美元);//过滤标题标签      $ str=preg_replace (“/& lt;(对象。* ?)在(. * ?)& lt;(\/对象。* ?)祝辞/si",““, str美元);//过滤对象标签   $ str=preg_replace (“/& lt; (\/objec。* ?)祝辞/si",““, str美元);//过滤对象标签      $ str=preg_replace (“/& lt; (noframes。* ?)在(. * ?)& lt; (\/noframes。* ?)祝辞/si",““, str美元);//过滤noframes标签   $ str=preg_replace (“/& lt; (\/noframes。* ?)祝辞/si",““, str美元);//过滤noframes标签      $ str=preg_replace (“/& lt;(我框架。* ?)在(. * ?)& lt;(\/我框架。* ?)祝辞/si",““, str美元);//过滤框标签   $ str=preg_replace (“/& lt;(\/?我?框架。* ?)祝辞/si",““, str美元);//过滤框标签      $ str=preg_replace (“/& lt;(脚本。* ?)在(. * ?)& lt;(\/脚本。* ?)祝辞/si",““, str美元);//过滤脚本标签   $ str=preg_replace (“/& lt;(\/脚本。* ?)祝辞/si",““, str美元);//过滤脚本标签   $ str=preg_replace (“/javascript/si",“Javascript", str美元);//过滤脚本标签   $ str=preg_replace(“/改变/si",“Vbscript", str美元);//过滤脚本标签   $ str=preg_replace(“在([a - z] +)/\ s *=/si",“在\ \ 1=?str美元);//过滤脚本标签   $ str=preg_replace(“/和#/si",,, #“, str美元);//过滤脚本标签,如javAsCript: alert (

清除空格,换行

函数DeleteHtml (str)美元   {   (str=削减美元str);   $ str=strip_tags (str美元,““);   $ str=ereg_replace (“\ t",““, str美元);   $ str=ereg_replace (“\ r \ n",““, str美元);   $ str=ereg_replace (“\ r",““, str美元);   $ str=ereg_replace (“\ n",““, str美元);   $ str=ereg_replace (““,“;“str美元);   返回修剪(str)美元;   }

过滤HTML属性

1,过滤所有HTML标签的正则表达式:

& lt;/?[^祝辞]+比;//过滤所有html标签的属性的正则表达式:      $ html=preg_replace (“/& lt; ([a-zA-Z] +)[^祝辞]*祝辞/?“& lt; \ \ 1在“,html美元);   

关于如何使用php正则去掉html属性问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注行业资讯频道了解更多相关知识。

如何使用php正则去掉html属性