[issue1708652] Exact matching

Tom Lynn report at bugs.python.org
Sat Sep 18 13:42:19 CEST 2010


Tom Lynn <tlynn at users.sourceforge.net> added the comment:

I'm still unsure.  I think this confusion does cause bugs in real-world code.  Perhaps more prominence for \A and \Z in the docs?  There's already a section comparing regexps starting '^' with match under "Matching vs Searching".

The problem is basically that ^ and $ have weird semantics but are better recognised than \A and \Z.  Looking over the docs again I see that the docs for $ are still misleading, in a way that's related to this issue:

    foo matches both 'foo' and 'foobar', while the regular
    expression foo$ matches only 'foo'.

"foo$ matches only 'foo' (out of 'foo' and 'foobar')" is the correct interpretation of that, but it's easy to read it as "foo$ means exact_match('foo')", which is the misconception I was hoping to put to rest with this (foo$ also matches the 'foo' part of 'foo\nbar', even with flags=0).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1708652>
_______________________________________


More information about the Python-bugs-list mailing list