Optional quantifier as anyone other supposed to be greedy by default, i.e. should match as much as possible.
Let's try to apply (AB)?.*B
regex to input AB
.
What I expect is that (AB)?
will greedily match full string, and there will be no more characters to match for the rest .*B
.
Actual behavior differs, it matches given input. Why?