in reply to Re^2: question about reg exp engine
in thread question about reg exp engine
Why does it run slower than running all three substitutions on different lines?Because the first three are all optimisable; they are all explicitly anchored to the beginning or end of the string, and the regex engine is smart enough to try the match only at the beginning or end of the string, respectively.
The combined pattern is too complex to be optimised, so the engine naively tries matching at every position in the (long) string.
Dave.
|
|---|