Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
matrixebiz
Level 9

function to extract text from a pile of returned text

not needed
0 Kudos
20 REPLIES 20
belltown
Level 9

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
https://github.com/belltown/
0 Kudos
EnTerr
Level 11

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
Level 9

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

not needed
0 Kudos
belltown
Level 9

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

What are you calling it with?
https://github.com/belltown/
0 Kudos
belltown
Level 9

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")
https://github.com/belltown/
0 Kudos
matrixebiz
Level 9

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

See below
0 Kudos
matrixebiz
Level 9

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

not needed
0 Kudos
belltown
Level 9

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.
https://github.com/belltown/
0 Kudos
matrixebiz
Level 9

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

not needed
0 Kudos