正则表达式 ctrl+f 但不包含“”并替换为文本

问题描述 投票:0回答:1

我一直在使用这个

(?<=(["']\b))(?:(?=(\\?))\2.)*?(?=\1)
,但它捕获了 Notepad++ 中所有具有
""
的文本。我想在行首和行尾添加。看起来像下面这样。

示例文本:

"Monsters Imprisoned by Essences have a {0}% chance to contain a Remnant of Corruption"

搜索结果:

Monsters Imprisoned by Essences have a {0}% chance to contain a Remnant of Corruption

没有

""

替换为:

<divine>{{
,并在找到的文本末尾添加
}}

最终结果:

<divine>{{Monsters Imprisoned by Essences have a {0}% chance to contain a Remnant of Corruption}}

需要一些正则表达式来查找没有

""
的行,并在找到的行的开头添加
<divine>{{
并在找到的行的末尾添加
}}

regex notepad++
1个回答
0
投票
  • Ctrl+H
  • 查找内容:
    (["'])(.+?)\1
  • 替换为:
    <divine>{{$2}}
  • 勾选环绕
  • SELECT 正则表达式
  • 全部替换

说明:

(["'])      # group 1, a quote
(.+?)       # group 2, 1 or more any character, not greedy
\1          # same kind of quote

截图(之前):

截图(之后):

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