That wouldn't explain the "got past" not being displayed. And it's actually not correct.
If the regular expression includes the g flag, the method returns an Array containing all matches. If there were no matches, the method returns null.
And as we hopefully all know: null doesn't have a property 'length', thus erroring out.