[Pcre-svn] [423] code/trunk/doc/pcre2pattern.3: Clarify rela…

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [423] code/trunk/doc/pcre2pattern.3: Clarify relative refence semantics.
Revision: 423
          http://www.exim.org/viewvc/pcre2?view=rev&revision=423
Author:   ph10
Date:     2015-11-10 14:50:51 +0000 (Tue, 10 Nov 2015)
Log Message:
-----------
Clarify relative refence semantics.


Modified Paths:
--------------
    code/trunk/doc/pcre2pattern.3


Modified: code/trunk/doc/pcre2pattern.3
===================================================================
--- code/trunk/doc/pcre2pattern.3    2015-11-10 14:33:28 UTC (rev 422)
+++ code/trunk/doc/pcre2pattern.3    2015-11-10 14:50:51 UTC (rev 423)
@@ -1,4 +1,4 @@
-.TH PCRE2PATTERN 3 "01 November 2015" "PCRE2 10.21"
+.TH PCRE2PATTERN 3 "10 November 2015" "PCRE2 10.21"
 .SH NAME
 PCRE2 - Perl-compatible regular expressions (revised API)
 .SH "PCRE2 REGULAR EXPRESSION DETAILS"
@@ -1671,6 +1671,9 @@
 .sp
   /(?|(abc)|(def))(?1)/
 .sp
+A relative reference such as (?-1) is no different: it is just a convenient way 
+of computing an absolute group number.
+.P
 If a
 .\" HTML <a href="#conditions">
 .\" </a>
@@ -2652,6 +2655,23 @@
 parentheses preceding the recursion. In other words, a negative number counts
 capturing parentheses leftwards from the point at which it is encountered.
 .P
+Be aware however, that if 
+.\" HTML <a href="#dupsubpatternnumber">
+.\" </a>
+duplicate subpattern numbers
+.\"
+are in use, relative references refer to the earliest subpattern with the 
+appropriate number. Consider, for example:
+.sp
+  (?|(a)|(b)) (c) (?-2)
+.sp
+The first two capturing groups (a) and (b) are both numbered 1, and group (c)
+is number 2. When the reference (?-2) is encountered, the second most recently
+opened parentheses has the number 1, but it is the first such group (the (a) 
+group) to which the recursion refers. This would be the same if an absolute 
+reference (?1) was used. In other words, relative references are just a 
+shorthand for computing a group number.
+.P
 It is also possible to refer to subsequently opened parentheses, by writing
 references such as (?+2). However, these cannot be recursive because the
 reference is not inside the parentheses that are referenced. They are always
@@ -3393,6 +3413,6 @@
 .rs
 .sp
 .nf
-Last updated: 01 November 2015
+Last updated: 10 November 2015
 Copyright (c) 1997-2015 University of Cambridge.
 .fi