Compare regular expressions

Thomas Dybdahl Ahle lobais at gmail.com
Tue Apr 17 22:12:30 CEST 2007


Den Tue, 17 Apr 2007 11:59:15 -0700 skrev Paddy:
> On Apr 17, 9:17 am, "Diez B. Roggisch" <d... at nospam.web.de> wrote:
>> Paddy schrieb:
>> > you could OR all the individual RE's test them all at once then find
>> > out which matched.
>>
>> > big_re = "|".join( r"(?P<__match_%i__>%s)" % (i, r)
>> >                    for i,r in enumerate(regexps) )
>>
>> This doesn't answer the question if two of the sub-expressions matched.

Hm, if I were to OR them all the time, then I wouldn't get any boost from 
compiling.

I'll probably just stick with a try them all solution, and then change it 
if I run into something that does the right thing. I believe it can make 
the code something like 7 or 10 times faster.



More information about the Python-list mailing list