From 594d70332e6d7552f1cb2180b59e1c78bea05ea1 Mon Sep 17 00:00:00 2001 From: Yves Orton Date: Wed, 7 Feb 2007 23:53:25 +0100 Subject: Re: [PATCH - provisional] H. Merijn Brands idea of buffer numbering. Message-ID: <9b18b3110702071353l250d8a67x188c4e234e8905c7@mail.gmail.com> p4raw-id: //depot/perl@30169 --- pod/perlre.pod | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'pod') diff --git a/pod/perlre.pod b/pod/perlre.pod index d913c8074a..5287965fe3 100644 --- a/pod/perlre.pod +++ b/pod/perlre.pod @@ -711,6 +711,29 @@ is equivalent to the more verbose /(?:(?s-i)more.*than).*million/i +=item C<(?|pattern)> +X<(?|)> X + +This is the "branch reset" pattern, which has the special property +that the capture buffers are numbered from the same starting point +in each branch. + +Normally capture buffers in a pattern are number sequentially, left +to right in the pattern. Inside of this construct this behaviour is +overriden so that the captures buffers in each branch share the same +numbers. The numbering in each branch will be as normal, and any +buffers following the use of this pattern will be numbered as though +the construct contained only one branch, that being the one with the +most capture buffers in it. + +Consider the following pattern. The numbers underneath are which +buffer number the captured content will be stored in. + + + # before ---------------branch-reset----------- after + / ( a ) (?| x ( y ) z | (p (q) r) | (t) u (v) ) ( z ) /x + # 1 2 2 3 2 3 4 + =item Look-Around Assertions X X X X -- cgit v1.2.1