Why do look-ahead and look-behind have to be fixed-width patterns?

Diez B. Roggisch deetsNOSPAM at web.de
Fri Jan 28 07:50:29 EST 2005

> but I don't understand why regex look-behinds (and look-aheads) have to be
> fixed-width patterns.
> i'm getting the impression that it's supposed to make searching
> exponentially slower otherwise

That's because of the underlying theory of regular expressions. They are
modelled using so called finite state automata (FSM). These are very much
limited in the complexity of things they can do, and so are regular
expressions. Explaining that further would require to dig deep into the
details of FSM, grammars and languages - deeper than I'm currently willing
to do :) But I wanted to point out that there is a "real" technical reason
for that, not just a lack of feature or willingness to implement one.



Diez B. Roggisch

More information about the Python-list mailing list