How to match where the search started?

MRAB python at
Tue Sep 28 19:54:05 CEST 2010

On 28/09/2010 17:32, Florian Kaufmann wrote:
>> If you want to anchor the regex at the start position 'pos' then use
>> the 'match' method instead.
> The wickedly problem is that matching at position 'pos' is not a
> requirement, its an option. Look again at my 2nd example, the
> r'(\=|.)...' part, which (of course wrongly) assumes that \= means
> 'match at the beginning of the search'. Before the match I am really
> interested in, there is the start of the search, OR there is any
> character.

An alternative is to use the 'regex' module, available from PyPI:

It has \G, which is the anchor for the start position.

More information about the Python-list mailing list