in reply to RE: RE (tilly) 2: Regex'ing backreferences
in thread Regex'ing backreferences
I rarely do. Unlike lookaheads with wildcards in them, the underlying implementation of mine is worst case off by a constant factor from the best possible. (The worst case, of course, being things like "foobababababafoo".) Furthermore my hope is that someday (not today of course) Perl's RE engine won't need such mechanical optimizations since it will do them on the fly.
And a question for you. While you unrolled it correctly, how many people here do you think would have got it right on their first or second try? (Or ever - most in my bet would have stopped before getting it right.) If your goal is correct code (which mine is) then be *very* careful before going through optimizations like this.
UPDATE
You did not, in fact, unroll it correctly. The string I gave above of a "worst case" in fact should match and does not match your regex!
|
|---|