regexp non-greedy matching bug?

Fredrik Lundh fredrik at pythonware.com
Sun Dec 4 06:23:56 EST 2005


Mike Meyer wrote:

> ^ must match the beginning of the string (BTW, you can get the same
> behavior by leaving off the ^ and using search instead of match).

that's backwards, isn't it?  using ^ with match is usually pointless (since
match only looks at the first position anyway), and using ^ with search
is also usually pointless...

(the only time you really need ^ is in certain multiline searches; depending
on what flags you use, ^ can match not only at the beginning of a string,
but also after each newline character in the target string)

</F>






More information about the Python-list mailing list