Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
sudo97
Visitor

roRegex

Hi, I need to parse m3u8 file with roRegex component.
For Example we have:
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=303000,CODECS="avc1.4d001f,mp4a.40.2",AUDIO="Audio1",RESOLUTION=320x240
link1
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=728000,CODECS="avc1.4d001f,mp4a.40.2",AUDIO="Audio1",RESOLUTION=640x360
link2
#EXT-X-STREAM-INF:PROGRAM-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 1
belltown
Roku Guru

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
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.