Notepad++ 如何为每个列出的项目添加引号、逗号、回车、3个空格,然后重复
我有一个长长的项目列表,如下所示:Notepad++ 如何为每个列出的项目添加引号、逗号、回车、3个空格,然后重复,notepad++,Notepad++,我有一个长长的项目列表,如下所示: item 1 item 2 item 3 item 2700 "item 1", "item 2", "item 3", "item 2700" 我需要它看起来像这样: item 1 item 2 item 3 item 2700 "item 1", "item 2", "item 3", "item 2700" Ctrl+H 查找内容:^.+$(\z)? 替换为:“$0”(?1:,) 检查环绕 检查正
item 1
item 2
item 3
item 2700
"item 1",
"item 2",
"item 3",
"item 2700"
我需要它看起来像这样:
item 1
item 2
item 3
item 2700
"item 1",
"item 2",
"item 3",
"item 2700"
- Ctrl+H
- 查找内容:
^.+$(\z)?
- 替换为:
“$0”(?1:,)
- 检查环绕
- 检查正则表达式
- 取消选中
。匹配换行符
- 全部替换
^ # beginning of line
.+ # 1 or more any character but newline
$ # end of line
(\z)? # optional group 1, end of file
# 3 spaces
"$0" # the whole match (i.e. one line), surrounded with quotes
(?1:,) # conditional replacement,
if group 1 exists (i.e. end of file)
do nothing
else
add a comma
"item 1",
"item 2",
"item 3",
"item 2700"
更换:
^ # beginning of line
.+ # 1 or more any character but newline
$ # end of line
(\z)? # optional group 1, end of file
# 3 spaces
"$0" # the whole match (i.e. one line), surrounded with quotes
(?1:,) # conditional replacement,
if group 1 exists (i.e. end of file)
do nothing
else
add a comma
"item 1",
"item 2",
"item 3",
"item 2700"
给定示例的结果:
^ # beginning of line
.+ # 1 or more any character but newline
$ # end of line
(\z)? # optional group 1, end of file
# 3 spaces
"$0" # the whole match (i.e. one line), surrounded with quotes
(?1:,) # conditional replacement,
if group 1 exists (i.e. end of file)
do nothing
else
add a comma
"item 1",
"item 2",
"item 3",
"item 2700"
屏幕截图:
^ # beginning of line
.+ # 1 or more any character but newline
$ # end of line
(\z)? # optional group 1, end of file
# 3 spaces
"$0" # the whole match (i.e. one line), surrounded with quotes
(?1:,) # conditional replacement,
if group 1 exists (i.e. end of file)
do nothing
else
add a comma
"item 1",
"item 2",
"item 3",
"item 2700"