正则表达式:查找不包含单词的标签,然后在替换位置插入该单词

问题描述 投票:-3回答:1

我有很多这样的链接:

<a href="love-management.html" title="See this" class="external" rel="category tag">

和这一个

<a href="https://love-management.html" title="See this" class="external" rel="category tag">

现在,这是第一种情况。我需要找到所有不包含https://的标签,然后插入以将其插入。

所以,基本上是:

<a href="love-management.html"

将成为

<a href="https://love-management.html"

但是,请注意不要重复https://之类的<a href="https://https://love-management.html"

regex notepad++
1个回答
0
投票

您可以使用否定的前瞻来断言还没有https://,因此您的Regex看起来像(<a href=")(?!https://)(.+")

然后,这只是替换为第一组,然后是https://,然后是第二组:$1https://$2

您可以尝试here

© www.soinside.com 2019 - 2024. All rights reserved.