use Benchmark; print "holli\n"; timethis (999999, sub { $_ = "fox comes and fox goes into forest"; s/(fox.+)(fox.+?forest)/${1}the $2/; }); print "borisz\n"; timethis (999999, sub { $_ = "fox comes and fox goes into forest"; s/(.*)(fox.+?forest)/$1the $2/; }); print "sh1tn\n"; timethis (999999, sub { $_ = "fox comes and fox goes into forest"; s/(?<=fox)(.+?)(fox)/$1the $2/; }); print "Roy Jonhson\n"; timethis (999999, sub { $_ = "fox comes and fox goes into forest"; s/(?=fox(?:(?!.*fox).)*forest)/the /; });