如何使用 Notepad++ 查找和替换多个文件中的行?

Sh3*_*erd 14 notepad++ find find-and-replace

我现在一直在使用记事本++,并且对如何执行此操作感到困惑:

我正在搜索的多个文件(在根目录中)中有一行。例子:

Brittany (File 1)
     PeopleSleptWith 2
Tiffany (File 2)
     PeopleSleptWith 4
Bonqueesh (File 3)
     PeopleSleptWith 3456
.
.
.
Run Code Online (Sandbox Code Playgroud)

我的目标是PeopleSleptWith用常量 (IE PeopleSleptWith 7)替换所有行,但是当我在多个文件中搜索和替换时,它不会删除完整的行,从而导致:

Brittany (File 1)
     PeopleSleptWith 7 2
Tiffany (File 2)
     PeopleSleptWith 7 4
Bonqueesh (File 3)
     PeopleSleptWith 7 3456
Run Code Online (Sandbox Code Playgroud)

在现实中我想要:

Brittany (File 1)
     PeopleSleptWith 7
Tiffany (File 2)
     PeopleSleptWith 7
Bonqueesh (File 3)
     PeopleSleptWith 7
Run Code Online (Sandbox Code Playgroud)

那么我如何继续寻找一个字符串,删除该行中的所有内容,并用另一个字符串替换它呢?

Vom*_*yle 24

使用 Notepad++ 在文件中的一行中查找字符串,并将整行替换为另一个字符串的匹配项

指示

打开Notepad++并按 Ctrl+F然后从Find in Files选项卡选项中。

现在你会...

  1. 将字符串放在Find What的正则表达式格式中 ^.*(PeopleSleptWith).*$

    • 字符串将位于“ ()”括号之间,如上所示#1
  2. 放置 5 个空格,然后替换为: PeopleSleptWith 7字符串

  3. 放置过滤器:作为*.**.txt任何您正在替换文件类型的明智之选
  4. 放置目录:您想要的位置(根文件夹
  5. 检查Regular expression选项
  6. 选择 Replace in Files
  7. 检查文件,现在一切都应该是正确的

    在此处输入图片说明