in reply to Re: Removing backtracking from a .*? regexp
in thread Removing backtracking from a .*? regexp
The observation is that positive lookahead combined with substr is about 12% faster than straight regexp with capture, which is not an insignificant speed improvement.
You are testing a highly sanitized version of the problem. The OP reduced it a barebones example. Surely the OP's logs do not begin with, nor even contain, the data shown, making it more complex to use substr to grab the right chunk of string. Secondly, your speed gain disappears entirely when you remove trailing backtracking from the loose regex as mentioned earlier. Try it with the this regex:
my $re_loose = qr/a=<(.*?$target[^>]+)>/;
Last, but most certainly not least: It is far too easy to reach unjustfied conclusions when benchmarking.
|
|---|