unexpected behaviour for python regexp: caret symbol almost useless?

Peter Otten __peter__ at web.de
Sun May 28 13:47:55 CEST 2006


conan wrote:

> The thing is i should expected to have to put caret explicitly to tell
> the regexp to match at the start of the line, something like:
> r'^<widget class=".*" id="(.*)">'
> however python regexp is taking care of that for me. This is not a
> desired behaviour for what i know about regexp, but maybe i'm missing
> something.

You want search(), not match().

http://docs.python.org/lib/matching-searching.html

Peter



More information about the Python-list mailing list