Regex teaser

Matt Lawrence matt.lawrence at
Wed Dec 4 10:31:50 GMT 2013

On 04/12/13 10:15, Smylers wrote:
> I agree the behaviour isn't immediately obvious. But it does make sense
> when thinking about what each component means separately.
> So what does seem bug-like to me is the Python behaviour — can anybody
> explain that?
It looks like Python has decided that a zero-width match cannot 
immediately follow a non-zero-width match. It seems to make zero-width 
matches in other circumstances as expected.


$ python -c "import re; print re.sub(r'$', '.', '')"


More information about the mailing list