php - 替换但在锚文本中除外
问题描述
是否可以替换 html 文本中的字符串,但除非它在超链接标签(锚文本)中。
例如:
The name of my dog is Mike. I always <a href="....">walk with my dog here</a>.
比用cat替换dog,而不是锚文本中的 dog 。所以结果应该是:
The name of my cat is Mike. I always <a href="....">walk with my dog here</a>.
解决方案
这只会在它不在>
and之间时选择“dog” </a>
。
(dog)+(?![^>]*\</a>)
推荐阅读
- html - Excel VBA - HTML 值为零时出现错误 91 问题
- tags - Amazon PA API5 - 附属公司的新产品链接结构?
- flutter - Flutter 放 AnimatedIcon 而不是 AppBar 前导图标
- c# - 为我的应用程序运行 Wix 安装程序后,即使在删除文件夹后也无法创建/写入文件/文件夹
- outlook - 从 Outlook 365 日历中完全删除某些内容
- linux - 如何在 linux 中显示来自 mlocate 的最新更新?
- sql - 无法对嵌套查询的结果添加 WHERE 约束 - postgres 中的错误 42883
- android - 如何将活动范围对象注入应用程序范围对象?
- javascript - 使用 JSON 文件作为数据库
- python - os.path.realpath(__file__) 没有返回预期的路径