Notepad++ 使用记事本++;

Notepad++ 使用记事本++;,notepad++,Notepad++,我正试图从.txt文件创建csv文件,现在我被困在这一点上 示例文本文件 http://website1.com/imageartist.png,Artis Name,Pop Rock https://website2/music/mymusicpop.mp3 https://website43.com/albumimages.png,Artis Name,K-Pop http://website7/music/mymusickpop.mp3 https://website23.com/an

我正试图从.txt文件创建csv文件,现在我被困在这一点上

示例文本文件

http://website1.com/imageartist.png,Artis Name,Pop Rock
https://website2/music/mymusicpop.mp3

https://website43.com/albumimages.png,Artis Name,K-Pop
http://website7/music/mymusickpop.mp3

https://website23.com/anotherimage.png,Artis Name,Heavy Metal
www.website5/music/mymusicmetal.mp3

www.website63.com/singerimage.png,Artis Name,Jazz
https.website5/music/mymusicjazz <-some lines have no .mp3 extension

如何使用notepad++?您可以使用notepad++上的正则表达式和反向引用

(([^\r\n]+))(\r\n)?(([^\r\n]+))(\r\n)?
已更新:这将忽略换行符类型

(([^\r\n]+))([\r\n])?(([^\r\n]+))([\r\n])?

\1--第一行URL

\4——第二行URL

\3--新行取自第3组


仅供参考:请勿多次运行(全部替换)。它将继续替换

这将连接由单个换行符分隔的行

  • Ctrl+H
  • 查找内容:
    ^.+\K\R(?!\R)
  • 替换为:
  • 检查环绕
  • 检查正则表达式
  • 取消选中
    。匹配换行符
  • 全部替换
说明:

^                   # beginning of line
  .+                # 1 or more any character but newline
  \K                # forget all we have seen until this position
  \R                # any kind of linebreak (i.e. \r, \n, \r\n)
  (?!\R)            # negative lookahead, make sure we haven't a linebreak after
屏幕截图(之前):

^                   # beginning of line
  .+                # 1 or more any character but newline
  \K                # forget all we have seen until this position
  \R                # any kind of linebreak (i.e. \r, \n, \r\n)
  (?!\R)            # negative lookahead, make sure we haven't a linebreak after

屏幕截图(之后):

^                   # beginning of line
  .+                # 1 or more any character but newline
  \K                # forget all we have seen until this position
  \R                # any kind of linebreak (i.e. \r, \n, \r\n)
  (?!\R)            # negative lookahead, make sure we haven't a linebreak after

我不明白你的问题是什么?获取您想要的文本,并将其保存为something.csv。就这样?@Philipp真正的问题不是创建csv文件,而是将2行合并为1行。。。但我不知道如何将它们与那样的模式结合起来。。。我不能用Ctrl+j,因为有成千上万行。你真的试过了吗?对我来说,这只是在每行的最后一个字符前插入一个逗号。如果你说,我相信你,但是我没有得到Npp 7.8.1的预期结果。对不起,我已经用EOL
\n
进行了测试,它与
\r\n
@Toto一起工作。你说得对。。。更好的解决方案应该是
([^\r\n]+)([\r\n])?([^\r\n]+)([\r\n])?
。无论新线是否中断