我有一长串看起来像这样的物品:
item 1
item 2
item 3
item 2700
我需要它看起来像这样:
"item 1",
"item 2",
"item 3",
"item 2700"
答案 0 :(得分:2)
^.+$(\z)?
"$0"(?1:,)
. matches newline
说明:
^ # 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"
屏幕截图: