On Wed Sep 21 12:04:45 2011, ph10@hermes.cam.ac.uk wrote: > On Wed, 21 Sep 2011, Father Chrysostomos via RT wrote: > > Oddly, I don’t find that counterintuitive at all. Do we need three > > versions of prune/then? > > Aha! One person's intuition is always another's totally craziness. :-) > I wonder what the percentages each way would be if we surveyed the > general Perl-using population? At least one other person thinks as I > do, because it was a bug report for PCRE - which was behaving more like > Perl - that got me into this issue in the first place. > > Is there a forum where we could ask the following question? > > Folks, consider the pattern ^A(B(*THEN)C), where A, B, and C are > complex patterns. If matching fails in C, do you expect that > (a) the entire match should fail, or > (b) the matching should backtrack into A? > > I will ask this question on the pcre-dev mailing list and see what > answers (if any) I get. I might try Jeffrey Friedl as well. I will not > be in the least offended if I am "outvoted". > > It seems that you intuitively think that a group without a | is a > different kind of animal to a group that contains a |, whereas I don't. > I just think that a group without a | has "one alternative", maybe > better expressed as "one branch" (since "alternative" implies at least > one of two). > > I can, however, understand your logic; I have to say that to me it seems > rather mathematically pedantic (with respect :-). > > I'd rather not created yet another version of prune/then! I *thought* I > understood these verbs. It seemed to me that they provide different > "strengths" of pruning when backtracked onto, as follows (from weakest > to strongest): Come to think of it, we already have your version of (*THEN), as (?>...). I know I’m just repeating what you said by that. But it has just occurred to me that it belongs at the top of this list. So your ^A(B(*THEN)C) translates into ^A((?>B)C). My understanding of (*THEN) (and perl’s implementation), would be [?>^A(B]C) where I’m using [?>...], as it doesn’t nest. So the latter meaning seems more useful, as there is no other way to get it. > *THEN fails the current alternation branch, and restarts at the next > alternation in the current group, or fails the whole group if there are > no more alternatives. > > *PRUNE fails the current match, but allows an advance to the next > starting position (unless anchored). > > *SKIP is like *PRUNE, but can skip forward more than one character. > > *COMMIT fails the entire matching process, not allowing any further > advance in the subject. > > That's fairly straightforward; the issue between us is what constitutes > "the current group". Having two verbs (one for me, one for you) is just > a recipe for even more confusion. > > Regards, > PhilipThread Previous | Thread Next