Multiple choice technology programming languages

/abc(?=def)/ matches?

  1. abc

  2. abcdef

  3. abcdefgh

  4. abcde

  5. II and III

Reveal answer Fill a bubble to check yourself
E Correct answer
Explanation

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.