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: 
matrixebiz
Roku Guru

function to extract text from a pile of returned text

not needed
0 Kudos
20 REPLIES 20
belltown
Roku Guru

Re: function to extract text from a pile of returned text

' Return array of <item> strings from string containing occurrences of: text=<item>, 
'
Function extractTextList (data As String) As Object
    list = []
    re = CreateObject ("roRegex", ".*?text=([^,]+),(.*)", "s")
    ma = re.Match (data)
    While ma.Count () > 2
        list.Push (ma [1])
        ma = re.Match (ma [2])
    End While
    Return list
End Function
0 Kudos
EnTerr
Roku Guru

Re: function to extract text from a pile of returned text

ifString.split() can get you started:
Brightscript Debugger> ? "blah, blah, blah, blah, text=1234, blah, blah, text=1234, blah, blah, blah, blah".split("text=")
<Component: roArray> =
[
   "blah, blah, blah, blah, "
   "1234, blah, blah, "
   "1234, blah, blah, blah, blah"
]
0 Kudos
matrixebiz
Roku Guru

Re: function to extract text from a pile of returned text

not needed
0 Kudos
belltown
Roku Guru

Re: function to extract text from a pile of returned text

What are you calling it with?
0 Kudos
belltown
Roku Guru

Re: function to extract text from a pile of returned text

If you can guarantee that each <item> in text=<item>, is a sequence of digits, you can use this regex:

re = CreateObject ("roRegex", ".*?text=(\d+),(.*)", "s")
0 Kudos
matrixebiz
Roku Guru

Re: function to extract text from a pile of returned text

See below
0 Kudos
matrixebiz
Roku Guru

Re: function to extract text from a pile of returned text

not needed
0 Kudos
belltown
Roku Guru

Re: function to extract text from a pile of returned text

re = CreateObject ("roRegex", ".*?text=(\d+)[^,]*,(.*)", "s")


should allow a sequence of digits then strip off anything else before the next comma.
0 Kudos
matrixebiz
Roku Guru

Re: function to extract text from a pile of returned text

not needed
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.