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

Re: roRegex question

Nice one! Clever use of the Replace.

Thanks again for your help. So far this seems like a good developer community. Smiley Very Happy

Cheers.
0 Kudos
Highlighted
Level 7

Re: roRegex question

Here is an attempt at a MatchAll function for any other developer needing this functionality. Smiley Surprised

I'm new to BRS, so feel free to educate if I could be doing anything better.

Thanks to TheEndless for the help and code.

Function MatchAll (pattern As String, subject As String, flags As String) As Object

regex = CreateObject("roRegex", pattern, flags)

response = Left(subject, Len(subject))

values = []
matches = regex.Match( response )

iLoop = 0
While matches.Count() > 1
values.Push( matches[ 1 ] )
' remove this instance, so we can get the next match
response = regex.Replace( response, "" )
matches = regex.Match( response )
' if we've looped more than 500 times, then we're
' probably stuck, so exit
iLoop = iLoop + 1
If iLoop > 500 Then
Exit While
End If
End While

Return values

End Function


Cheers.
0 Kudos
Highlighted
Level 9

Re: roRegex question

Hello, I'm trying to return the numbers only after text=  (1234) from the below line;
whatever?text=1234","name":"whatever

CreateObject ("roRegex", ".*?text=([^,]+),(.*)", "s")
Gives me 1234"

*,(.*)", "s")
Gives me 0

What is wrong? Thank you
0 Kudos
Highlighted
Level 9

Re: roRegex question

@matrixieBiz - your question is already here https://forums.roku.com/viewtopic.php?f ... 82#p544813
Please do not pollute this 6-year old thread with it.
0 Kudos
Highlighted
Level 9

Re: roRegex question

Doing a search brought up this tread also so thought I would post here as well to get more exposure. 

I can't find good documentation on what all the "*,(.*)", "s")" does
0 Kudos
Highlighted
Level 7

Re: roRegex question

Posting the same question in two places just makes it harder for people to find answers in the future.  Polluting the forum with unnecessary posts to get your own questions "more exposure" in not appropriate.  I am closing this thread.

--Mark
0 Kudos