我有这个文本文件,我需要在其中重复向下移动一行。
这是原始文件
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 行要向下移动。
(^.*?specific-word.*)(\R)(.+)$3$2$1. matches newline解释:
( # 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)
截图(之前):
截图(之后):
| 归档时间: |
|
| 查看次数: |
1319 次 |
| 最近记录: |