Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
used together in the following manner: $NP = "(?:(?:$np1)*\s*$np2*(?:$np3)+)"; As I've mentioned, I want to match the longest patterns first but allow for matching on the smaller patterns, which is my reason for including Kleene stars for optional subpatterns. The problem that I'm having is that the optionality leads to matching the minimal patterns and never the optionally longer ones. My question then is whether I need to do as I am now doing, and matching the longest patterns, or the next longest, and so on down to the minimal patterns ? I ask because the OR grouping from greatest coverage to least seems to also be missing longer patterns. So to sum, I need to match long patterns composed of smaller patterns where the long ones match first, then failing that, the long ones match. If my question is overly simple, or my discussion of it unclear, I apologize in advance Thanks,$np1="(?:$det|$gen)"; $np2 ="(?:$adj|$num|$conj|$adv|$inf)"; $np3="(?:$np1*\s*($noun)*\s*$np2*\s*($noun)+\s*$adj*)";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(Ovid) Re: greedy and lazy
by Ovid (Cardinal) on Jul 25, 2000 at 00:02 UTC | |
by Anonymous Monk on Jul 25, 2000 at 00:08 UTC | |
by chromatic (Archbishop) on Jul 25, 2000 at 08:45 UTC | |
by merlyn (Sage) on Jul 25, 2000 at 08:49 UTC | |
by oconnelm (Initiate) on Jul 26, 2000 at 02:30 UTC |