in reply to Re: Re: Peeling the Peelings
in thread Peeling the Peelings

They don't need to. You just have to tell the regex engine exactly what you want. The regex he used has no anchors - why? There's also a bunch of useless capturing parens, and in fact one paren pair that's completely superfluous. All of that is not what we wanted. I've got no Perl here, so I'll have to test this later, but I'm pretty positive that the following works as specified, and very certain that it'll perform tons better.
/\A (?> (?> [^(]* \( ) {$lvl} ) ( .+ ) \) {$lvl} \z/x;

Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Re^3: Peeling the Peelings
by bobn (Chaplain) on Jul 02, 2003 at 13:30 UTC
    Strangley enough, the benchmarks indictate this is no better. comparison w/ minor rewrites: Results:
    Benchmark: timing 7000 iterations of OP best: get_proparg_new, my best +: getpropstr, orig-arg2, yours... OP best: get_proparg_new: 3 wallclock secs ( 2.39 usr + 0.01 sys = +2.40 CPU) @ 2916.67/s (n=7000) my best: getpropstr: 4 wallclock secs ( 1.72 usr + 0.01 sys = 1.73 +CPU) @ 4046.24/s (n=7000) orig-arg2: 12 wallclock secs ( 9.71 usr + 0.04 sys = 9.75 CPU) @ 71 +7.95/s (n=7000) yours: 12 wallclock secs ( 9.69 usr + 0.03 sys = 9.72 CPU) @ 72 +0.16/s (n=7000)


    --Bob Niederman, http://bob-n.com