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: 
matrixebiz
Level 7

function to extract text from a pile of returned text

not needed
0 Kudos
20 Replies
belltown
Level 7

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 8

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 7

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

not needed
0 Kudos
Highlighted
belltown
Level 7

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 7

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 7

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

See below
0 Kudos
matrixebiz
Level 7

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

not needed
0 Kudos
belltown
Level 7

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 7

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

not needed
0 Kudos