Thomas Dybdahl Ahle schrieb: > 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): ...
It's not. For the simplest of expressions one might come up with a relation between them, but even that would be hard. General case? No chance. Diez -- http://mail.python.org/mailman/listinfo/python-list