So, here is the getColorWildcard function from the Other.lua file as is (with a few new lines put in for readability).
As is, it has a couple of problem. First, it starts at the second character, but doesn't realize it (the first character position for selectSection is 0, not 1). So that is an easy fix, just change the 1 to a 0 in the for loop. It also means the if statement looking at i to set startc isn't needed, and startc can always be i+1. The second, bigger problem is that it doesn't work for single characters of a given color, and instead thinks the color continues to the end of the string. This is because it doesn't set endc until after a second character is found of that color, and string.sub with no second argument returns the rest of the string starting from the start point. This can be fixed by just declaring endc when startc is declared. Here is a corrected version.