在 php 项目中,经常要用到一些过滤标签的正则表达式,收藏一下备用:

$str=preg_replace("/\s+/", " ", $str); //过滤多余回车

$str=preg_replace("/

$str=preg_replace("//si","",$str); //注释

$str=preg_replace("//si","",$str); //过滤DOCTYPE

$str=preg_replace("//si","",$str); //过滤html标签

$str=preg_replace("//si","",$str); //过滤head标签

$str=preg_replace("//si","",$str); //过滤meta标签

$str=preg_replace("//si","",$str); //过滤body标签

$str=preg_replace("//si","",$str); //过滤link标签

$str=preg_replace("//si","",$str); //过滤form标签

$str=preg_replace("/cookie/si","COOKIE",$str); //过滤COOKIE标签

$str=preg_replace("/(.*?)/si","",$str); //过滤applet标签

$str=preg_replace("//si","",$str); //过滤applet标签

$str=preg_replace("/(.*?)/si","",$str); //过滤style标签

$str=preg_replace("//si","",$str); //过滤style标签

$str=preg_replace("/(.*?)/si","",$str); //过滤title标签

$str=preg_replace("//si","",$str); //过滤title标签

$str=preg_replace("/(.*?)/si","",$str); //过滤object标签

$str=preg_replace("//si","",$str); //过滤object标签

$str=preg_replace("/(.*?)/si","",$str); //过滤noframes标签

$str=preg_replace("//si","",$str); //过滤noframes标签

$str=preg_replace("/(.*?)/si","",$str); //过滤frame标签

$str=preg_replace("//si","",$str); //过滤frame标签

$str=preg_replace("/(.*?)/si","",$str); //过滤script标签

$str=preg_replace("//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标签

php常用标签,PHP 过滤常用标签的正则表达式相关推荐

  1. jq查找字段忽略html标签,jQuery过滤HTML标签并高亮显示关键字的方法

    本文实例讲述了jQuery过滤HTML标签并高亮显示关键字的方法.分享给大家供大家参考.具体如下: jQuery实现网页关键字过滤效果,将需要过滤的文字定义在JavaScript中,可定义多个,不过要 ...

  2. php语句过滤掉html标签_php过滤HTML标签、属性等正则表达式

    php过滤HTML标签.属性等正则表达式 本文是百分网小编搜索整理的使用代码实例给出了过滤HTML内容的正则表达式,具体说明请参阅代码中的注释,感兴趣的朋友一起学习吧!!想了解更多相关信息请持续关注我 ...

  3. js 正则表达式过滤html标签,js过滤html标签的方法

    在js中,可以通过 replace() 方法,将一串含有html标签的字符串中的html标签过滤掉,本文就来详细的介绍一下,js中过滤html标签的方法. js replace() 方法定义与介绍 r ...

  4. php语句过滤掉html标签_php过滤html标签

    标签: php自带函数strip_tags echo strip_tags("hello world! "); 自定义函数: function filterhtml($str) { ...

  5. PHP中过滤常用标签的正则表达式

    $str=preg_replace("/\s+/", " ", $str); //过滤多余回车 $str=preg_replace("/<[ ] ...

  6. php 正则过滤style,PHP 过滤常用标签的正则表达式

    $str=preg_replace("/\s+/", " ", $str); //过滤多余回车 $str=preg_replace("/ $str=p ...

  7. PHP过滤常用标签的正则表达式

    <?php$str=preg_replace("/\s+/", " ", $str); //过滤多余回车 $str=preg_replace(" ...

  8. Python正则匹配HTML,python正则匹配html标签_Python爬虫常用正则表达式及HTML网页标签分析总结...

    这篇文章主要是介绍Python爬取网页信息时,经常使用的正则表达式及方法.它是一篇总结性文章,实用性比较大,主要解决自己遇到的爬虫问题,也希望对你有所帮助~ 当然如果会Selenium基于自动化测试爬 ...

  9. python正则匹配html标签_Python爬虫常用正则表达式及HTML网页标签分析总结

    这篇文章主要是介绍Python爬取网页信息时,经常使用的正则表达式及方法.它是一篇总结性文章,实用性比较大,主要解决自己遇到的爬虫问题,也希望对你有所帮助~ 当然如果会Selenium基于自动化测试爬 ...

最新文章

  1. 【Hibernate】Hibernate基本原理及概念详解
  2. php魔术方法 效率,PHP常用魔术方法的性能探究
  3. Unity2018.2中文更新日志速览版
  4. ZOJ Problem Set - 1008
  5. 开发者友好性和易用性
  6. 20190904:(leetcode习题)合并两个有序数组
  7. ubuntu防火墙关闭命令-转
  8. virtualbox 安装 虚拟机的时候报错不能创建新任务
  9. 自学python买什么教材-Python 有哪些入门学习方法和值得推荐的经典教材?
  10. java io知识点汇总FIle类
  11. 迅雷11抢先体验版,免费2T空间可离线不限速取回
  12. 2021-10-28
  13. oracle 快速检索表名称及包含的字段名称
  14. c++编译STL文件反转其法线
  15. 华为机试真题 C 实现【非严格递增连续数字序列】【2022 Q4新题】
  16. 用html做完整网页效果
  17. [8]Deep Learning Software-深度学习软件
  18. 嵌入式设备的网络性能该如何分析
  19. 传感器的灵敏度 分辨率与分辨力和精度 + 光纤光缆
  20. 网新恒天2011 9 21招聘会笔试题

热门文章

  1. 【Oracle】用户管理
  2. HDU 6444 Neko's loop(单调队列)
  3. redis基础学习(一)— 配置项
  4. 统计面要素中点要素的个数.
  5. Nginx 从入门到放弃(五)
  6. [日志]08/19/2007
  7. 前端每日实战:123# 视频演示如何用纯 CSS 创作一架双冀飞机
  8. 11.18 Apache用户认证11.19/11.20 域名跳转11.21 Apache访问日志
  9. Virtual Box创建共享目录
  10. 框架源码深入需要准备的知识之解析XML