使用记事本++

时间:2019-11-26 12:20:13

标签: notepad++

iam试图从.txt文件创建csv文件,现在iam卡在了这一点

示例文本文件

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

我想要这样

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

如何使用记事本++做到这一点?

2 个答案:

答案 0 :(得分:0)

您可以在Notepad ++上使用正则表达式,并使用反向引用

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

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

enter image description here

enter image description here

\ 1-第一行网址

\ 4-第二行网址

\ 3-新行来自第3组

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

答案 1 :(得分:0)

这将合并由单个换行符分隔的行。

  • Ctrl + H
  • 查找内容:^.+\K\R(?!\R)
  • 替换为:,
  • 检查 环绕
  • 检查 正则表达式
  • 取消检查 . matches newline
  • 全部替换

说明:

^                   # 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

屏幕截图(之前):

enter image description here

屏幕截图(之后):

enter image description here