in reply to Re^2: substituting capture groups substrings (?...)
in thread substituting capture groups substrings

Hello 1nickt,

I can’t answer for tye, but I think the following test script is instructive:

#! perl use strict; use warnings; use Benchmark qw(cmpthese); my $source = '37 35 37 8 17 16 25 36 37 3840 42 42 42 40'; my $target = '37 35 37 8 17 16 25 36 37 38 40 42 42 42 40'; cmpthese ( 1e8, { capture => capture ($source), lookaround => lookaround($source), } ); sub capture { my ($line) = @_; $line =~ s/([0-9]{2})([0-9]{2})/$1 $2/g; die unless $line eq $target; } sub lookaround { my ($line) = @_; $line =~ s/(?<=[0-9]{2})(?=[0-9]{2})/ /g; die unless $line eq $target; }

Output:

1:19 >perl 1307_SoPW.pl Rate capture lookaround capture 87642419/s -- -34% lookaround 133333333/s 52% -- 1:20 >

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,