将所有行合并到记事本++上

时间:2019-10-10 10:45:05

标签: notepad++

我有以下列表:

  

32229_071
   32225_041
   32225_011
   32225_011
   32225_011

我希望它看起来像

  

'32229_071','32225_041','32225_011','32225_011','32225_011'

如何在Notepad ++中做到这一点?

2 个答案:

答案 0 :(得分:2)

  • Ctrl + H
  • 查找内容:(?:^|\G)(.+)(?:(\R)|\z)
  • 替换为:'$1'(?2,:)
  • 检查 环绕
  • 检查 正则表达式
  • 取消检查 . matches newline *
  • 全部替换

说明:

(?:^|\G)        # non capture group, beginning of line or restart from last match position
(.+)            # group 1, 1 or more any character but newline
(?:             # non capture group
  (\R)          # group 2, any kind of linebreak
 |              # OR
  \z            # end of file
)               # end group

替换:

'$1'            # content of grop 1  between single quotes
(?2,:)          # conditional replace, if group 2 exists then a comma else nothing

屏幕截图(之前):

enter image description here

屏幕截图(之后):

enter image description here

答案 1 :(得分:0)

  1. 转到替换(ctrl + h)
  2. 搜索 \ r \ n
  3. 替换
  4. 选中扩展(左下)
  5. 添加第一个和最后一个报价

然后替换!

enter image description here

相关问题