bcrowell2 has asked for the wisdom of the Perl Monks concerning the following question:
O Monks,
This article http://swtch.com/~rsc/regexp/regexp1.html critizes Perl's regexp engine and gives an example where it performs very badly. I'm trying to convert the example, given in pseudocode, into real perl code, and not succeeding. Can anyone help?
Here are the things I can't figure out:
(1) They use a repetition count n twice. This could mean either that (a) the two counts have to be the same, or that (b) they could be different. Which one would make sense here?
(2) In case (a), I don't know how to code the constraint on the counts into a perl regexp. In case (b), I get this perl -e 'if (("a" x 29)=~/(a?)*a*/) {print 1}', which doesn't have the poor performance they claim.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: regexp puzzle
by kennethk (Abbot) on Jan 06, 2011 at 00:41 UTC | |
by bcrowell2 (Friar) on Jan 06, 2011 at 01:35 UTC | |
|
Re: regexp puzzle
by syphilis (Archbishop) on Jan 06, 2011 at 00:50 UTC | |
|
Re: regexp puzzle
by scorpio17 (Canon) on Jan 06, 2011 at 15:30 UTC | |
|
Re: regexp puzzle
by BrowserUk (Patriarch) on Jan 06, 2011 at 16:19 UTC |