我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

正则表达式匹配包含特定数据的标签

I need help to make a reg exp. to match these: The goal is to match any html tag that only <br/> or/and spaces.

<p><br/></p>
<h1><br/></h1>
<p><br/><br/></p>
<span><br/><br/></span>
<b><br/>   <br/>    </b>
<h2><br/>   <br/>    </h2>

Try:

preg_match_all('#<([\S]+)[^>]*>(\s*|(<br\s*/>)*)*</\\1>#i', $html, $m);

If you want to strip elements that contain only comments as well as whitespace/<br/>, that's going to be a pain, maybe even impossible, using regex alone.

近期文章

  • 通过SWIG回绕C回调
  • $ _POST在php中不起作用
  • Php会话不起作用
  • 带有PHP表单的错误2048
  • 如何为我的网站创建在线pdf合并?
  • email2db开源替代[关闭]
  • Controller的模型查询功能::如何在Controller中调用w / pagination?
  • MySQL,需要一些关于如何为包含大量页面的网站设置站点地图的建议吗?
  • 为什么我不能删除这个项目? 没有意义
  • PHP查找是否存在不同顶级文件夹中的文件
  • 如何使用db和fallback执行Zend_Locale?
  • Web Service不会在请求之间保持状态
  • php / mysql显示所选复选框的数据
  • 有没有办法在没有DOM的xml文件上编写/删除?
  • DomDocument和两个字节写的特殊字符
  • 从空值创建默认对象
  • 正则表达式帮助:子域检查
  • 未捕获的PDOException:获取模式需要colno - 但仅在生产服务器上
  • php中的多朋友选择器
  • 按间隔显示零的组

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华