如何在Notepad++中匹配整个行以进行搜索/替换?

时间:2021-07-25 16:52:20

I'd like to do a bulk line-by-line replace on a file within Notepad++ like so:

我想在Notepad++这样的文件中做一个大范围的逐行替换:

This is my line of text that I would like to replace

to

"This is my line of text that I would like to replace" +

I tried the following:

我试着以下:

Find: ^$ Replace: "\1" +

发现:^ $代替:“\ 1”+

Find: ^()$ Replace: "\1" +

发现:^()美元取代:“\ 1”+

Find: (^$) Replace: "\1" +

发现:(^)美元取代:“\ 1”+

Any hints? Thanks in advance!

有提示吗?提前谢谢!

4 个解决方案

#1


20  

Try to search for ^(.*)$ and replace with "\1" +

试着搜索^(. *)和“\ 1”取代美元+

The difference between this and your's is that this one captures all characters between the starting and ending of the string. Your regexes simply tries to capture nothing.

这个和你的不同之处在于它捕获了字符串开始和结束之间的所有字符。您的regex只是尝试不捕获任何内容。

#2


4  

Try this:

试试这个:

Find: ^(.*?)$

Replace: "\1" +

#3


1  

This should work:

这应该工作:

Find (.*) replace "\1" +

查找(.*)替换“\1”+

#4


1  

Try this and see if it works for you:

试试这个,看看是否适合你:

Find: ^(.+)$ Replace: "\1" +

发现:^(+)取代美元:\ 1 +

#1


20  

Try to search for ^(.*)$ and replace with "\1" +

试着搜索^(. *)和“\ 1”取代美元+

The difference between this and your's is that this one captures all characters between the starting and ending of the string. Your regexes simply tries to capture nothing.

这个和你的不同之处在于它捕获了字符串开始和结束之间的所有字符。您的regex只是尝试不捕获任何内容。

#2


4  

Try this:

试试这个:

Find: ^(.*?)$

Replace: "\1" +

#3


1  

This should work:

这应该工作:

Find (.*) replace "\1" +

查找(.*)替换“\1”+

#4


1  

Try this and see if it works for you:

试试这个,看看是否适合你:

Find: ^(.+)$ Replace: "\1" +

发现:^(+)取代美元:\ 1 +