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: 
ratish
Visitor

roRegex not accepting roString or String

I am trying to implement a search, where user enters the characters on the keyboard and I use the search String to lookup channels from a list matching.
The keyboard returns the entered string as roString.
If i pass this string to regExOb = CreateObject("roRegex", searchString, "i") , and then call  regExOb.IsMatch(channel.channelName) does not return true even if it does match.
If i hardcode the searchString, the isMatch() function seems to function properly.

I even tried regExOb = CreateObject("roRegex", searchString.toStr(), "i"), but did not work.

Please help me to understand why roRegex does not accepts roString or String as matching-pattern. 
0 Kudos
3 REPLIES 3
joetesta
Roku Guru

Re: roRegex not accepting roString or String

Based on what you described I tried an experiment;


    searchstring = "whatever"
    ? " ------ type of searchstring is "; type(searchString)
    regExOb = CreateObject("roRegex", searchString, "i")
    channel = "I watch whatever I want"
    ? "regExOb is match ? "; regExOb.IsMatch(channel)


 ------ type of searchstring is String
regExOb is match ? true



    mystring = "whatever"
    list = CreateObject("roList")
    list.Addtail(mystring)
    searchstring = list.GetTail()
    ? " ------ type of searchstring is "; type(searchString)
    regExOb = CreateObject("roRegex", searchString, "i")
    channel = "I watch whatever I want"
    ? "regExOb is match ? "; regExOb.IsMatch(channel)


 ------ type of searchstring is roString
regExOb is match ? true

I know this doesn't answer your question but maybe it explains that the problem is something different than what you thought?  My understanding of the docs is that roString and regular old String should be interchangeable here.
aspiring
0 Kudos
joetesta
Roku Guru

Re: roRegex not accepting roString or String

0 Kudos
ratish
Visitor

Re: roRegex not accepting roString or String

Thanks. I had to go with the Instr() approach. Will try once again what could be the issue.
In my case the both strings to regex were of type roString. 
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.