Multiple choice technology programming languages

/abc(?!def)/ matches

  1. abc

  2. abcdef

  3. abcd

  4. abdef

  5. I and III

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

The regex uses a negative lookahead (?!def) to match the string 'abc' only if it is not immediately followed by 'def'. Therefore, it successfully matches 'abc' (I) and 'abcd' (III) because 'abc' in 'abcd' is followed by 'd'. It fails on 'abcdef'.