prints: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 /; });
/me wins ;-)holli timethis 999999: 10 wallclock secs ( 9.87 usr + 0.00 sys = 9.87 CPU) + @ 101275.98/s (n=999999) borisz timethis 999999: 14 wallclock secs (11.08 usr + 0.00 sys = 11.08 CPU) + @ 90268.91/s (n=999999) sh1tn timethis 999999: 12 wallclock secs (10.41 usr + 0.01 sys = 10.42 CPU) + @ 95959.98/s (n=999999) Roy Jonhson timethis 999999: 10 wallclock secs (10.19 usr + 0.02 sys = 10.20 CPU) + @ 98000.69/s (n=999999)
In reply to Re^2: regexp find last word
by holli
in thread regexp find last word
by Murcia
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |