【发布时间】:2021-06-22 01:13:07
【问题描述】:
HTML 代码
<div class="thx_thanked_post"><a title="Click to enlarge" target="_blank" data-fancybox="data-2581" data-type="image" href="images/thx/star.png"><img src="images/thx/star.png" alt="Better response on post dqwdqwdqwqdwdqwqwdwdwd" class="thx_thanked_post_img"></a>Just a "quick" overview of what's good and why.<br>
<a title="Click to enlarge" target="_blank" data-fancybox="data-2581" data-type="image" href="images/thx/kek.png"><img src="images/thx/kek.png" alt="Better response on post dqwdqwdqwqdwdqwqwdwdwd" class="thx_thanked_post_img"></a>
<br>
Note: Hyper speed is referenced multiple times here. This is a bug(?) where after reaching speeds over 160 km/h, you continue accelerating like crazy while traveling in a straight line, allowing you to reach speeds of over 500 km/h with a good boost under ideal conditions. Making good use of hyper speed when possible is huge for cutting time, and much of what makes something good is how easily and consistently it works to give hyper speed.<br>
我想排除带有“stars.png”的<img>标签,由<a>标签括起来。
我的正则表达式:
<a [^>]*\>([\t]|[\n])*<img[^>]*^(?!.*star\.png$)[^>]*\>([\t]|[\n])*<\/a>
它不起作用。这没什么。
正确匹配应该只拾取第二个 <a> 标记与 <img> 具有“images/thx/kek.png”但没有“images/thx/star.png”。
【问题讨论】:
-
JavaScript? Python? php?将适用的标签添加到帖子中。
-
@zer00ne 这是 php,对不起。但基本上我正在测试regex101.com/r/R3P1eF/1
-
在test 中没有任何文字与
star更接近。只需删除该正则表达式并输入 star 并没有匹配项。