How to match where the search started?

Florian Kaufmann sensorflo at gmail.com
Tue Sep 28 10:10:07 CEST 2010


>From the documentation:

7.2.4. Regular Expression Objects, search(string[, pos[, endpos]])
... the '^' pattern character matches at the real beginning of the
string and at positions just after a newline, but not necessarily at
the index where the search is to start....

But I'd like to do just that. In Emacs regexps, I think the closest
equivalent would be \=. Then I could do something like that, and also
find directly adjacent matches

reo = re.compile( r'(\=|...)...' );
while True
  mo = reo.search(text,pos)
  if not mo: break
  ...

Flo



More information about the Python-list mailing list