Compare regular expressions

Thomas Dybdahl Ahle lobais at gmail.com
Mon Apr 16 05:50:40 EDT 2007


Hi, I'm writing a program with a large data stream to which modules can 
connect using regular expressions.

Now I'd like to not have to test all expressions every time I get a line, 
as most of the time, one of them having a match means none of the others 
can have so.

But ofcource there are also cases where a regular expression can 
"contain" another expression, like in:
"^strange line (\w+) and (\w+)$" and "^strange line (\w+) (?:.*?)$" in 
which case I'd like to first test the seccond and only if it mathces test 
the seccond.

Do anybody know if such a test is possible?
if exp0.contains(exp1): ...



More information about the Python-list mailing list