php - 使用 PHP 在 html 字符串中删除 AMP 页面的自定义标签
问题描述
我在编写正则表达式方面不是那么好,所以我寻求帮助。
我有我的页面的 html 字符串。我想将 html 字符串转换为 Google AMP 兼容页面。我想在其中替换一些自定义 html 标签。
<define:dos> This string explains DOS.</define:dos>
并且输出应该只有This string explains DOS.
我的 html 字符串中有几个字符串,从我尝试通过为每个按预期工作的标签<define:
单独编写来删除它们:preg_replace
$html = preg_replace('#<define:wlan>#i', '', $html);
$html = preg_replace('#<define:wifi>#i', '', $html);
$html = preg_replace('#<define:dos>#i', '', $html);
等等
我尝试了以下方法但没有奏效:(
$html = preg_replace('#\<define[^\]>*\](.*?)\</define\>#m', "$1", $html);
我想要通用的解决方案。请帮忙。
先感谢您。
解决方案
推荐阅读
- javascript - Knex 在 for 循环中承诺
- firebase - Firestore 规则将用户限制在他们的数据库部分
- javascript - 使用表单插入多行值时出错
- javascript - 如何将 JQuery 与 getElementsById 一起使用?
- macos - Safari 中的屏幕共享功能如何工作?
- c# - 通过谷歌api创建文件夹到谷歌驱动器后没有得到文件夹ID作为响应
- ios - 在设置 Github Actions iOS 项目期间,进程完成并退出代码 66
- javascript - 如何在包含具有对象名称的对象的对象内的javascript中使用地图
- scala - 使用自定义 Scala 库列出配置的依赖项
- kubernetes - Kubernetes 混合配置映射和主机路径