首页 > 解决方案 > 在记事本++上将所有行合并为一个

问题描述

我有以下列表:

32229_071
32225_041
32225_011
32225_011
32225_011

我希望它看起来像

'32229_071'、'32225_041'、'32225_011'、'32225_011'、'32225_011'

我如何在记事本++中做到这一点?

标签: notepad++

解决方案


  • Ctrl+H
  • 找什么:(?:^|\G)(.+)(?:(\R)|\z)
  • 用。。。来代替:'$1'(?2,:)
  • 检查 环绕
  • CHECK 正则表达式
  • 取消选中 . matches newline*
  • Replace all

解释:

(?:^|\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

屏幕截图(之前):

在此处输入图像描述

屏幕截图(之后):

在此处输入图像描述


推荐阅读