Regexp optimization question
Magnus Lie Hetland
mlh at furu.idi.ntnu.no
Fri Apr 23 11:43:20 EDT 2004
In article <c69aqq$3h2$06$1 at news.t-online.com>, Martin v. Löwis wrote:
>Magnus Lie Hetland wrote:
>> I've tried to speed this up by using the same trick as SPARK, putting
>> all the regexps into a single or-group in a new regexp. That helped a
>> *lot* -- but now I have to find out which one of them matched at a
>> certain location.
>
>Are you using the .lastindex attribute of match objects yet?
Dang! I thought I had read the docs ;)
Seems very useful. I actually need to know all the matches, because
which one gets selected depends on the current priorities (ordering)
in the parser, and cannot be fixed for the scanner. (I could put the
patterns in the or-group in reverse prioritized order, but that would
have to be fixed...)
Thanks for the tip, anyway.
>Martin
--
Magnus Lie Hetland "Wake up!" - Rage Against The Machine
http://hetland.org "Shut up!" - Linkin Park
More information about the Python-list
mailing list