Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
sudo97
Level 7

roRegex

Hi, I need to parse m3u8 file with roRegex component.
For Example we have:
#EXT-X-STREAM-INFSmiley TongueROGRAM-ID=1,BANDWIDTH=303000,CODECS="avc1.4d001f,mp4a.40.2",AUDIO="Audio1",RESOLUTION=320x240
link1
#EXT-X-STREAM-INFSmiley TongueROGRAM-ID=1,BANDWIDTH=728000,CODECS="avc1.4d001f,mp4a.40.2",AUDIO="Audio1",RESOLUTION=640x360
link2
#EXT-X-STREAM-INFSmiley TongueROGRAM-ID=1,BANDWIDTH=1137000,CODECS="avc1.4d001f,mp4a.40.2",AUDIO="Audio1",RESOLUTION=640x360
link3

and I need to find all 3 links. I tried this:
function FindEXTX(str) 
r = CreateObject("roRegex", "#EXT-X-STREAM-INF:.*\n(.*)", "")
print r.Match(str)
end function


and this prints nothing. But when I test my Regex-expression on https://regex101.com/ it works okay
0 Kudos
1 Reply
belltown
Level 7

Re: roRegex

Try this:


sub Main ()
m3u8 = ReadAsciiFile ("pkg:/m3u8/test.m3u8")
for each link in FindEXTX(m3u8)
print link
end for
end sub

function FindEXTX(str) as object
linkList = []
splitList = CreateObject ("roRegex", "\n", "").Split (str)
for i = 1 to splitList.Count () - 1 step 2
linkList.push(splitList [i])
end for
return linkList
end function
https://github.com/belltown/
0 Kudos