in reply to Re^2: regexp find last word
in thread regexp find last word
use strict; use warnings; use Benchmark 'cmpthese'; cmpthese( -2, { holli => sub { $_ = "fox comes and fox goes into forest"; s/(fox.+)?(fox.+?forest)/${1}the $2/; }, Roy => sub { $_ = "fox comes and fox goes into forest"; s/(?=fox(?:(?!fox).)*forest)/the /; }, ikegami => sub { $_ = "fox comes and fox goes into forest"; s/(fox(?:(?!fox).)*forest)/the $1/; }, });
Rate ikegami holli Roy ikegami 34714/s -- -2% -27% holli 35541/s 2% -- -25% Roy 47659/s 37% 34% --
|
|---|