Fix an off-by-one error in RegEx lastMatch calculation, and add a test for it.