notepad ++如何在以下单词后插入替换

时间:2019-06-24 04:09:35

标签: replace notepad++ boundary

text: [aa-b c d...]
result: [b-123 c d...]

text:[aa-word1 word2 word3 ...]
result[word1-123 word2 word...]

[aa-bananas oranges apples]
[bananas-123 oranges apples]

我想替换aa-,但是-123应该仅放在下一个单词之后。 下一个单词应该是一个参数,而不是像插入aa-这样的固定文本。这是因为有很多不同的情况需要替换。

我将“ aa-”更改为许多其他变体。 “ bb-”“ cc-” ... 但是word1始终是文本中的变量。

1 个答案:

答案 0 :(得分:0)

  • Ctrl + H
  • 查找内容:\[aa-(\w+)
  • 替换为:[$1-123
  • 检查匹配大小写
  • 检查环绕
  • 检查正则表达式
  • 全部替换

说明:

\[          # opening square bracket
aa          # literally 2 a
-           # hyphen
(\w+)       # group 1, 1 or more word character

给定示例的结果

[b-123 c d...]
[word1-123 word2 word3 ...]
[bananas-123 oranges apples]

屏幕截图:

enter image description here

相关问题