Reputation: 5998
I have the following file:
#EXTM3U
#EXTINF:36,Armand van Helden Featuring La Rok - Let Me Lead You
C:\Users\Public\Music\Sample Music\Armand van Helden Featuring La Rok - Let Me Lead You.mp3
#EXTINF:19,Ann Nesby - Loving is Really My Game
C:\Users\Public\Music\Sample Music\Ann Nesby - Loving is Really My Game.mp3
#EXTINF:19,Thomas Toccafondi feat. Kaysee - I've Changed (Earnshaw & Jones Remix)
C:\Users\Public\Music\Sample Music\Thomas_Toccafondi_feat._Kaysee-I've_Changed_(Earnshaw_&_Jones_Remix)-DUFF028-1(320k).mp3
#EXTINF:57,Terry Hunter feat. Terisa Griffin - Wonderful (Abicah Soul's Wonderful Remix)
C:\Users\Public\Music\Sample Music\Terry_Hunter_feat._Terisa_Griffin-Wonderful_(Abicah_Soul's_Wonderful_Remix)-TB005-1(320k).mp3
I am trying to write a regular expression that will parse out artist and title into two separate groups so the first group would contain the artist:
Armand van Helden Featuring La Rok
Ann Nesby
Thomas Toccafondi feat. Kaysee
Terry Hunter feat. Terisa Griffin
And the second group would contain the title:
Let Me Lead You
Loving is Really My Game
I've Changed (Earnshaw & Jones Remix)
Wonderful (Abicah Soul's Wonderful Remix)
The parsed information should come from the part right after #EXTINF: followed by any number. I want to ignore the actual file name.
Any help is appreciated.
Thanks
Upvotes: 1
Views: 877
Reputation: 91428
/^#EXTINF:\d+,(.*?) - (.*)/
Artists are in group 1
Titles are in group 2
Upvotes: 1
Reputation: 679
artists:
/^#EXTINF:\d+,([^-]+) - /
titles:
/^#EXTINF:\d+,[^-]+ - (.+)/
Upvotes: 0
Reputation: 51
If all of the tracks have the same format (#, Artist - Track) then I would use find the '-' in every line, take whats before it as the #, Artist and whatever is after it as the Track. It would just be a simple -. Then you can do some processing on it to split it up. For the Artist you can use a lookahead/lookbehind or just a [0-9]+, then grab the rest of the line.
Hope that helps!
Upvotes: 0