Notepad+ RegEx搜索/替换:如何在每个文件行的开始和结束添加和前置字符?

时间:2022-01-15 15:30:08

How to append and prepend a character at start and end of each file line?

如何在每个文件行的开始和结束时追加和添加一个字符?

I have this file structure:

我有这个文件结构:

140","Bosnia
160","Croatia
170","Serbia
180","Montenegro
200","Slovenia

What I need is to add a double quote " at the start and at the end of each file line, using regular expressions in Notepad++ editor.

我需要在每个文件行的开头和结尾添加一个双引号,使用Notepad++ editor中的正则表达式。

Thanks!

谢谢!

2 个解决方案

#1


22  

Just search for

只是搜索

(.*)

and replace with

和替换

"\1"

with regular expression option activated. Regular expressions are working only on a row bases, so (.*) matches the complete row and because of the brackets around you can access the match using \1.

使用正则表达式选项激活。正则表达式只在行基上工作,所以(.*)匹配完整的行,由于周围的括号,您可以使用\1访问匹配。

#2


4  

Try searching ^(.*)$ and replacing by "$1".

尝试搜索^(. *)和“$ 1”取代美元。

bye ;)

再见。)

#1


22  

Just search for

只是搜索

(.*)

and replace with

和替换

"\1"

with regular expression option activated. Regular expressions are working only on a row bases, so (.*) matches the complete row and because of the brackets around you can access the match using \1.

使用正则表达式选项激活。正则表达式只在行基上工作,所以(.*)匹配完整的行,由于周围的括号,您可以使用\1访问匹配。

#2


4  

Try searching ^(.*)$ and replacing by "$1".

尝试搜索^(. *)和“$ 1”取代美元。

bye ;)

再见。)