Tim Peters added the comment: It's working fine. `.search()` always finds the leftmost position at which the pattern matches. In your example, the pattern '1?' does match at index 0: it first tries to match `1' at index 0. That's the greedy part. The attempt fails, so it next tries to match the empty string at index 0. That succeeds, which you can see by printing search.span(0) (which displays (0, 0)).
Of course you'd get exactly the same result if you tried matching `1*` instead. But you'd get a different result from matching '1+', because that pattern does _not_ match at index 0. In that case the engine has to move to index 1 to get a match. And if you search the string '11' with the pattern '1?`, you'll see that it does match the slice 0:1. If, as you claimed, ? were not greedy, it would match the empty string 0:0 instead. ---------- nosy: +tim.peters _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue19964> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com