in reply to Re^5: A regex that only matches at offset that are multiples of a given N? (Update:almost perfect!)
in thread A regex that only matches at offset that are multiples of a given N?
that is effectively similar to simply ignoring non-aligned matched ... How so?
Although embedding the called-back code within the regex as a zero-length code assertion looks like its not exiting the regex engine; the effect on performance shows that the need to set-up and tear down a scope and invoke that code has a very significant effect:
$s='a'x1e6; cmpthese -1, { a => q[ $s =~ m[(.)(?{$c=pos();})]g; ], b => q[ $s =~ m[(.)]g; ], };; Rate a b a 3924/s -- -100% b 4206322/s 107088% --
If it was possible to avoid running 3 orders of magnitude slower, the benefits would be enormous for my application.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: A regex that only matches at offset that are multiples of a given N? (Update:almost perfect!)
by smls (Friar) on Feb 13, 2013 at 21:11 UTC | |
by BrowserUk (Patriarch) on Feb 13, 2013 at 23:12 UTC |