import re
a = re.compile('^a(?!abc)')
b = re.compile('^a(?!bac)$')
c = re.compile('^a((?!ba).)*$')
a1 = "abbc"
print(a.search(a1)) # <re.Match object; span=(0, 1), match='a'>
print(b.search(a1)) # None
print(c.search(a1)) # <re.Match object; span=(0, 4), match='abbc'>
I don't understand the expression "?!" in python Regular expression.
Why is only a searched in the first case?
I wonder if all the characters of abbc can be searched because it is a match that the string abc does not come next.
Why is b none?
Doesn't it all apply to abbc since it starts with a and doesn't end with bac?