How to get the "longest possible" match with Python's RE module?
Tim Peters
tim.peters at gmail.com
Tue Sep 12 01:16:27 EDT 2006
[Licheng Fang]
> ...
> I want to know if there is some way to make Python RE behave like grep
> does,
Not in general, no. The matching strategies couldn't be more
different, and that's both deep and intentional. See Friedl's book
for details:
http://regex.info/
> or do I have to change to another engine?
Yes, if POSIX regexp semantics are what you require. Several years
ago there was an extension module for Python supplying POSIX
semantics, but I couldn't find anything current just now in a minute
of searching. You may be more motivated to search longer ;-)
More information about the Python-list
mailing list