I want to parse a file containing multiple lines. I will loop through the newlines to extract the information i need. I am trying to write a m3u parser which uses regex - i already succesfully made one using sting position and substring.
I want to parse this line:
#EXTINF:-1 tvg-ID="NPO 2 HD NL" tvg-name="NL : Npo 2" tvg-logo="http://www.iptv-plus.net:25461/images/Astra23picon/1_0_19_17C0_C82_3_EB0000_0_0_0.png" group-title="Holland",NL : Npo 2
So i came up with these regexpressions:
(?<=group-title=")(.*?)(?=")
(?<=tvg-name=")(.*?)(?=")
(?<=tvg-logo=")(.*?)(?=")
(?<=tvg-ID=")(.*?)(?=")
(?<=,)(.*?)$
These will extract the tvg tags, and extract the name from the end of the line (always after the last occuring comma.)
What i would like is to put all these regexpressions in one regex, so i can get an array containing all elements. I tried using | but that is an OR? i believe.. I can use them seperate, but i think it might be faster to put them all in 1? Also i would like to create named groups. But when i change it to
(?<group><=group-title=")(.*?)(?=")
it takes the lookbehind as text (<=).. Can i and how can i combine lookbehind with named groups? I like to use the regex in javascript, but could also implement a php that parses the m3u file and returns a json.