in reply to Re: regexp find last word
in thread regexp find last word
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)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: regexp find last word
by Crackers2 (Parson) on Mar 02, 2005 at 15:45 UTC | |
by Anonymous Monk on Mar 03, 2005 at 10:46 UTC | |
|
Re^3: regexp find last word
by Roy Johnson (Monsignor) on Mar 02, 2005 at 16:00 UTC | |
|
Re^3: regexp find last word
by ikegami (Patriarch) on Mar 02, 2005 at 15:45 UTC | |
by Roy Johnson (Monsignor) on Mar 02, 2005 at 15:50 UTC | |
|
Re^3: regexp find last word
by valentin (Abbot) on Mar 02, 2005 at 21:12 UTC |