mainmanc
Visitor

Re: roRegex question

Nice one! Clever use of the Replace.

Thanks again for your help. So far this seems like a good developer community. 😄

Cheers.
Tags (1)
0 Kudos
mainmanc
Visitor

Re: roRegex question

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

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

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

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

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
Tags (1)
0 Kudos
RokuMarkn
Visitor

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
Tags (1)
0 Kudos
Community is Temporarily in Read-Only Mode!

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. You will not be able to log in or post new comments or kudos 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 12 and you may notice reduced functionality. In the meantime, for additional assistance, visit our Support Site.

Thanks for your patience — we’re excited to share what’s next!