re.rsearch?

Quinn Dunkan quinn at vomit.ugcs.caltech.edu
Sun Jun 23 22:00:17 EDT 2002


On Sun, 23 Jun 2002 22:10:01 GMT, Fredrik Lundh <fredrik at pythonware.com> wrote:
>Quinn Dunkan wrote:
>> Occaisionally I find myself wanting an re.search that will find the rightmost
>> match.
>
>just prepend ".*" to the pattern...

Oh, I should have thought of that :)  Of course, that changes the match, but
I can get my span with ()s and m.span(1)

>> Unfortunately, AFAIK, re.search also lacks a 'start_searching_at'
>> type option.
>
>if you use a compiled pattern, you can pass in start
>and end offsets:
>
>    p = re.compile(pattern)
>    p.search(string, start, end)

Phoey... don't know how I missed that one in the docs.  Guess I looked at
the modules search() and assumed the method was the same...

thanks!



More information about the Python-list mailing list