regexp short-circuit the first match for alternate matches. For example,
(A|AA)$ matches only the last character in
On the other hand, POSIX regex (C, C++, Boost, Ruby) would demand that the longest leftmost match is returned, i.e
AA. Most modern engines seem to reject this on the basis that it makes the engine terribly slow (because it cannot match alternates eagerly).
However, the leftmost longest overall match behavior can be quite useful in some situations, where otherwise workarounds are needed and it looks like there is currently no engine for Python which supports this behaviour.
It would be nice to have the POSIX behaviour of the longest submatch as an option when compiling a regular expression.