I'm not sure what the output is like but it sounds like you need to add a `$` at the end of the regexp to ensure that you match all the way to the end of the line.  Otherwise calls to `.match()` below will only care about prefix matches anchored from the beginning of the string.