I am working in Python 3 and
i am a bit confused about negative lookahead.
When i use regex pattern (?!123)ABC
, do i understand it right if i say that i am looking for a string 'ABC' but only if it does NOT continue with '123'?
CODE:
import re
print(re.search(r'(?!123)ABC', "ABC123"))
>>><_sre.SRE_Match object; span=(0, 3), match='ABC'>
Question here is, why is 'ABC' matched even if it continues with '123'?
This is just an example code, i am trying to understand the logic here.
Thank you for any explanation!