Developers

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
Tags (1)
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
Tags (1)
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"
]
Tags (1)
0 Kudos
matrixebiz
Roku Guru

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

not needed
Tags (1)
0 Kudos
belltown
Roku Guru

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

What are you calling it with?
Tags (1)
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")
Tags (1)
0 Kudos
matrixebiz
Roku Guru

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

See below
Tags (1)
0 Kudos
matrixebiz
Roku Guru

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

not needed
Tags (1)
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.
Tags (1)
0 Kudos
matrixebiz
Roku Guru

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

not needed
Tags (1)
0 Kudos
Community is Being Upgraded!

We’re upgrading Roku Community to bring you a faster, more mobile-friendly experience. You may notice limited functionality or read-only access during this time. Read more here.

Planned Downtime:
Community will be unavailable for up to 24–48 hours during the upgrade window during the week of May 19th and you may notice reduced functionality. In the meantime, for additional assistance, visit our Support Site.

We're sorry for this disruption — we’re excited to share what’s next!