Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
renojim
Community Streaming Expert

roRegEx issue

I just noticed that a really long regular expression ReplaceAll can make the box look like it's screwed up. I was using an roRegEx to replace all the >'s with ">" in a string and I didn't notice that the string I was receiving from my server was something like 267k bytes long. I thought the box was locked up, but I could press Home and get back to the main menu and I could move the selection to different channels, but selecting a channel just made the sound and nothing happened. I rebooted the box before I figured out what the real problem was (don't try to ReplaceAll on a string that long, it takes quite a while). Anyway, I guess pressing Home doesn't really kill off everything the way I thought it did.

-JT
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
4 REPLIES 4
kbenson
Visitor

Re: roRegEx issue

What was your match regex and replace string? If it was non-trivial (or even it it was only sort of trivial), it can be easy to create a regex that uses exponentially increasing time/operations for each extra character. Those can usually be refactored into a cleaner implementation.

I'm not sure about PCRE, but I know just using a matching group "()" compared to a non-matching group "(?:)" utilizes more resources.

P.S. No, PCRE is not really the same as the Perl regex engine, just MOSTLY Perl compatible, so I can't be sure about how it's functioning unless I really look into it, even if I know how it works in Perl.
-- GandK Labs
Check out Reversi! in the channel store!
0 Kudos
kbenson
Visitor

Re: roRegEx issue

"kbenson" wrote:

I'm not sure about PCRE, but I know just using a matching group "()" compared to a non-matching group "(?:)" utilizes more resources.


Whoops, meant to say that I'm not sure about PCRE, but I know in Perl...
-- GandK Labs
Check out Reversi! in the channel store!
0 Kudos
renojim
Community Streaming Expert

Re: roRegEx issue

I was just trying to replace ">" with ">".
 r = CreateObject("roRegEx",">",""
str2 = r.ReplaceAll(str1,">")

I wasn't really commenting on the amount of time it took. I think if you're trying to process a 267 kbyte string all at once you're probably doing something wrong. I was commenting on the fact that it looks like a ReplaceAll is not interrupted by pressing Home. I've been going on the assumption that pressing Home kills off everything, but I suppose there are some things that can't be canceled/aborted. It looked like my box was sort of locked up, but I suppose if I had just waited for the ReplaceAll to finish everything would have been ok.

For what it's worth, I only discovered this because I was reviving my attempt at a PlayOn channel after I saw scyber's effort. I wasn't having much luck with his channel, so I went back to try my own. PlayOn returns something that is basically xml, except that "<" and ">" are replaced with "&lt;" and "&gt;". I never thought I'd get a "directory" that was 267k long, so it looked like the box was locked up when it was just processing the regular expression. I'm starting to realize that PlayOn requires a faster connection than what I have. I really hate to shell out more money, so I may have to live without it.

-JT
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
kbenson
Visitor

Re: roRegEx issue

Ah, I get it. Yeah, I've seen instances where pressing home doesn't take for a few seconds. I think it may have something to do with whether a component is busy or BightScript itself is. It may have problems interrupting components that are blocking.
-- GandK Labs
Check out Reversi! in the channel store!
0 Kudos