【发布时间】:2019-04-02 17:03:43
【问题描述】:
我正在尝试编写一个正则表达式来查找没有 alt 属性的 img 标签。
这是正则表达式。
<img\s+src.+^(?!alt).+$
这里有一些示例
<img src="smiley.gif" alt="Smiley face" height="42" width="42">
<img src="smiley2.gif" height="42" width="42">
<img src="smiley3.gif" alt="Smiley face Three" height="42" width="42">
这里是 regex101 的链接 https://regex101.com/r/Z5vkQb/3/
【问题讨论】:
-
试试
<img\b(?![^>]*? alt=)[^>]*>