Unfortunately, the regex implementation on the Roku only supports finding the first match in a string. There’s no way that I’m aware of to find all matches. You could potentially use roRegex.Split to split the string into an array and count the entries, but that may drop empty strings.
“TheEndless” wrote:
You could potentially use roRegex.Split to split the string into an array and count the entries, but that may drop empty strings.
roRegEx.split() does not drop empty strings. So it will work but is brutal. Here is a slightly better way:
BrightScript Debugger> s = "ha |fg d a a aa a a |"
BrightScript Debugger> ? len(s) - len(s.replace("a", ""))
7
roRegEx.replaceAll() can do the same for a pattern - or if multiple stats are to be accounted, just roll over the string and collect in a dictionary.