ratish
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2017
02:45 AM
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.
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.
3 REPLIES 3
joetesta
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2017
09:53 AM
Re: roRegex not accepting roString or String
Based on what you described I tried an experiment;
------ type of searchstring is String
regExOb is match ? true
------ 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.
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
joetesta
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2017
10:36 AM
Re: roRegex not accepting roString or String
Another thing you might try is instr() > 0
https://sdkdocs.roku.com/display/sdkdoc/Global+String+Functions#GlobalStringFunctions-Instr(startasI...
https://sdkdocs.roku.com/display/sdkdoc/Global+String+Functions#GlobalStringFunctions-Instr(startasI...
aspiring
ratish
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2017
11:18 PM
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.
In my case the both strings to regex were of type roString.