如何在记事本++中自动选择并向下移动以某些文本开头的行

use*_*774 5 notepad++ batch

我有这个文本文件,我需要在其中重复向下移动一行。

这是原始文件

txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-
txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-
txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-
specific-word txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-
txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-
Run Code Online (Sandbox Code Playgroud)

这是我需要的文件

txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-
txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-
txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-
txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-
specific-word txt-txt-txt-txt-txt-txt-txt-txt-txt-txt-
Run Code Online (Sandbox Code Playgroud)

特定单词enter code here是相同的,但该行的其余部分不同,我需要将其仅向下移动一行。

我在单击该行并选择向下移动该行的选项后使用了行操作,或者键盘快捷键 ctrl shift down

然而,我希望有另一个自动化,因为该文件非常大,包含超过 20k 行要向下移动。

Tot*_*oto 8

  • Ctrl+H
  • 找什么:(^.*?specific-word.*)(\R)(.+)
  • 用。。。来代替:$3$2$1
  • 检查 匹配大小写
  • 检查 环绕
  • 检查 正则表达式
  • 取消选中 . matches newline
  • Replace all

解释:

(       # start group 1
  ^       # beginning of line
  .*?     # 0 or more any character but newline, not greedy
  specific-word   # the word to search
  .*      # 0 or more any character but newline
)       # end group 1
(\R)    # group 2, any kind of linebreak
(.+)    # group 3, 1 or more any character but newline
Run Code Online (Sandbox Code Playgroud)

替代品:

$3      # content of group 3, the second line
$2      # content of group 2, linebreak
$1      # content of group 1, the first line
Run Code Online (Sandbox Code Playgroud)

截图(之前):

在此输入图像描述

截图(之后):

在此输入图像描述