The regex /abc(?=def)/ uses a positive lookahead (?=def), which matches "abc" only when followed immediately by "def". Both "abcdef" and "abcdefgh" satisfy this condition - they contain "abc" immediately followed by "def" - so the pattern matches in both cases. The lookahead doesn't consume characters.