summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2011-07-24 17:44:12 +0000
committerph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2011-07-24 17:44:12 +0000
commit068606023eed60b8e58ffd671a79bd4a5f9923ac (patch)
tree9861d474ccfe53c4d68cc8f0aa320ab8c7be8f82 /doc
parent8bfb0e4b9f3b6940eace67788c60d6e2245e0001 (diff)
downloadpcre-068606023eed60b8e58ffd671a79bd4a5f9923ac.tar.gz
Permit quantifiers on parenthesized assertions.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@637 2f5784b3-3f2a-0410-8824-cb99058d5e15
Diffstat (limited to 'doc')
-rw-r--r--doc/pcrecompat.312
-rw-r--r--doc/pcrepattern.334
2 files changed, 33 insertions, 13 deletions
diff --git a/doc/pcrecompat.3 b/doc/pcrecompat.3
index 89dc267..97e598c 100644
--- a/doc/pcrecompat.3
+++ b/doc/pcrecompat.3
@@ -20,10 +20,12 @@ in the main
.\"
page.
.P
-2. PCRE does not allow repeat quantifiers on assertions. Perl permits them, but
-they do not mean what you might think. For example, (?!a){3} does not assert
-that the next three characters are not "a". It just asserts that the next
-character is not "a" three times.
+2. PCRE allows repeat quantifiers only on parenthesized assertions, but they do
+not mean what you might think. For example, (?!a){3} does not assert that the
+next three characters are not "a". It just asserts that the next character is
+not "a" three times (in principle: PCRE optimizes this to run the assertion
+just once). Perl allows repeat quantifiers on other assertions such as \b, but
+these do not seem to have any use.
.P
3. Capturing subpatterns that occur inside negative lookahead assertions are
counted, but their entries in the offsets vector are never set. Perl sets its
@@ -171,6 +173,6 @@ Cambridge CB2 3QH, England.
.rs
.sp
.nf
-Last updated: 23 July 2011
+Last updated: 24 July 2011
Copyright (c) 1997-2011 University of Cambridge.
.fi
diff --git a/doc/pcrepattern.3 b/doc/pcrepattern.3
index 38e9689..1a5747a 100644
--- a/doc/pcrepattern.3
+++ b/doc/pcrepattern.3
@@ -1438,7 +1438,7 @@ items:
an escape such as \ed or \epL that matches a single character
a character class
a back reference (see next section)
- a parenthesized subpattern (unless it is an assertion)
+ a parenthesized subpattern (including assertions)
a recursive or "subroutine" call to a subpattern
.sp
The general repetition quantifier specifies a minimum and maximum number of
@@ -1829,12 +1829,30 @@ those that look ahead of the current position in the subject string, and those
that look behind it. An assertion subpattern is matched in the normal way,
except that it does not cause the current matching position to be changed.
.P
-Assertion subpatterns are not capturing subpatterns, and may not be repeated,
-because it makes no sense to assert the same thing several times. If any kind
-of assertion contains capturing subpatterns within it, these are counted for
-the purposes of numbering the capturing subpatterns in the whole pattern.
-However, substring capturing is carried out only for positive assertions,
-because it does not make sense for negative assertions.
+Assertion subpatterns are not capturing subpatterns. If such an assertion
+contains capturing subpatterns within it, these are counted for the purposes of
+numbering the capturing subpatterns in the whole pattern. However, substring
+capturing is carried out only for positive assertions, because it does not make
+sense for negative assertions.
+.P
+For compatibility with Perl, assertion subpatterns may be repeated, even though
+it makes no sense to assert the same thing several times. In practice, there
+only three cases:
+.sp
+(1) If the quantifier is {0}, the assertion is never obeyed during matching.
+However, it may contain internal capturing parenthesized groups that are called
+from elsewhere via the
+.\" HTML <a href="#subpatternsassubroutines">
+.\" </a>
+subroutine mechanism.
+.\"
+.sp
+(2) If quantifier is {0,n} where n is greater than zero, it is treated as if it
+were {0,1}. At run time, the rest of the pattern match is tried with and
+without the assertion, the order depending on the greediness of the quantifier.
+.sp
+(3) If the minimum repetition is greater than zero, the quantifier is ignored.
+The assertion is obeyed just once when encountered during matching.
.
.
.SS "Lookahead assertions"
@@ -2761,6 +2779,6 @@ Cambridge CB2 3QH, England.
.rs
.sp
.nf
-Last updated: 22 July 2011
+Last updated: 24 July 2011
Copyright (c) 1997-2011 University of Cambridge.
.fi