-2

This is the string I'm working on (a part of a html file):

"Tracklist:01. Jai Uttal & Ben Leinbach - Govinda (Holmes Ives Remix)02. Edu Imbernon & Los Suruba - Fayer 03. Hankat - Be The First (Rosenstand Remix)04. Matthias Vogt - Seven Summits05. Mike Dem & Richfield feat. Sowelu - I Got My Soul06. Stergios - City Groove07. Roman Flügel - Teenage Engineering08. Mario Basanov feat. Monica Liu - Move On09. Rufus T - Dreamwork10. Arctic Lake - For Us (Huxley Remix)11. Chew Fu feat. Steve Clisby - Purple Rain (Mousse T's Home A Lone Mix)12. Ryan Davis - Brun (Matthias Meyer Remix)13. Martin Waslewski - Rasberry Heaven"

I can't find the regular expression that associated with findall() is going to give me :

[01. Jai Uttal & Ben Leinbach - Govinda (Holmes Ives Remix),02. Edu Imbernon & Los Suruba - Fayer ,03. Hankat - Be The First (Rosenstand Remix),04. Matthias Vogt - Seven Summits,05. Mike Dem & Richfield feat. Sowelu - I Got My Soul,06. Stergios - City Groove,07. Roman Flügel - Teenage Engineering,08. Mario Basanov feat. Monica Liu - Move On,09. Rufus T - Dreamwork10. Arctic Lake - For Us (Huxley Remix),11. Chew Fu feat. Steve Clisby - Purple Rain (Mousse T's Home A Lone Mix),12. Ryan Davis - Brun (Matthias Meyer Remix),13. Martin Waslewski - Rasberry Heaven ]

I got r('\d{2}\.\s{2}....') but after \s{2} I can't find any pattern that works.

Any help would be greatly appreciated.

Yannick
  • 1,550
  • 4
  • 18
  • 27

2 Answers2

1

I tried this. I think this will help you to find all.

/\d{2}.*/
Mohamed Rafiq P
  • 758
  • 1
  • 7
  • 17
1

This regex will match every track and return all of them. Check the demo. It works also if there are numbers in titles (as long as they are not followed by a dot).

/\d{2}\.\s+.+?(?=\d{2}\.|$)/g
Egan Wolf
  • 3,533
  • 1
  • 14
  • 29
  • wow it seems to work thank you !!! I ll really have to analyze and understand the end of this regex, it was a bit of a hard one for a first day of learn regex so thanks for your help – Yannick Jul 10 '17 at 23:47
  • this Look ahead feature is what I was looking for, now I'm trying to adapt this regex to only have the \artist + track name\ and not the \d{2}\.\s{2} at the beginning – Yannick Jul 10 '17 at 23:57
  • got it :) /(?<=\d{2}\.\s).+?(?=\d{2}\.|$)/g Thanks to you I learned a lot :) – Yannick Jul 11 '17 at 00:11
  • And I learned something thanks to you :) About the un-greedy operator `.+?`. Check [here](https://stackoverflow.com/a/7124976/5722505). – Egan Wolf Jul 11 '17 at 06:05
  • Its more complicated that it seems when you really go deep into it :) I never read about Look Ahead and Look Behind before, the un-greedy operator was still a bit obscure – Yannick Jul 11 '17 at 14:58