stijnvs has asked for the wisdom of the Perl Monks concerning the following question:
Hello monks,
The perlre man page states:
By default, a quantified subpattern is "greedy", that is, it will match as many times as possible (given a particular starting location) while still allowing the rest of the pattern to match.
Hence, when trying the following simple program:
"abc" =~ /(a|ab)*(bc|c)/; print "$1 $2\n";
One would expect the output to be ab c. Executing the above program with Perl version 5.8.3 returns a bc however.
My question now is: which one is wrong, me, the man page or the implementation?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Greedy regexp matching: differences between man page and implementation?
by Corion (Patriarch) on Jul 08, 2004 at 13:27 UTC | |
by perldeveloper (Scribe) on Jul 08, 2004 at 13:47 UTC | |
Re: Greedy regexp matching: differences between man page and implementation?
by Roy Johnson (Monsignor) on Jul 08, 2004 at 13:45 UTC | |
Re: Greedy regexp matching: differences between man page and implementation?
by japhy (Canon) on Jul 08, 2004 at 13:48 UTC | |
Re: Greedy regexp matching: differences between man page and implementation?
by davido (Cardinal) on Jul 08, 2004 at 16:02 UTC |
Back to
Seekers of Perl Wisdom