I thought a qualifier would become non-greedy if I put " ? " after it. So I expected that I could get " ax: yz_bc " as the returned string by the following code:
import re
data = 'aaaaaax: yz_bcd'
p = re.compile('a.*?bc')
ret = p.search(data)
if ret is not None:
print(f'{ret.group(0)}')
else:
print('Not matched')
However, the string which was actually returned was " aaaaaax: yz_bc ". It was the same string which the code returned when " ? " was not added. How to explain this phenomenon? Is it because the match must start from the leftmost?
And what change should I make to my code to get " ax: yz_bc " as the returned string?