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

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
joetesta
Level 10

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

Re: roRegex not accepting roString or String

0 Kudos
ratish
Level 7

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