| 2074 |
ways the + and * repeats can carve up the subject, and all have to be tested |
ways the + and * repeats can carve up the subject, and all have to be tested |
| 2075 |
before failure can be reported. |
before failure can be reported. |
| 2076 |
.P |
.P |
| 2077 |
At the end of a match, the values set for any capturing subpatterns are those |
At the end of a match, the values of capturing parentheses are those from |
| 2078 |
from the outermost level of the recursion at which the subpattern value is set. |
the outermost level. If you want to obtain intermediate values, a callout |
| 2079 |
If you want to obtain intermediate values, a callout function can be used (see |
function can be used (see below and the |
|
below and the |
|
| 2080 |
.\" HREF |
.\" HREF |
| 2081 |
\fBpcrecallout\fP |
\fBpcrecallout\fP |
| 2082 |
.\" |
.\" |
| 2084 |
.sp |
.sp |
| 2085 |
(ab(cd)ef) |
(ab(cd)ef) |
| 2086 |
.sp |
.sp |
| 2087 |
the value for the capturing parentheses is "ef", which is the last value taken |
the value for the inner capturing parentheses (numbered 2) is "ef", which is |
| 2088 |
on at the top level. If additional parentheses are added, giving |
the last value taken on at the top level. If a capturing subpattern is not |
| 2089 |
.sp |
matched at the top level, its final value is unset, even if it is (temporarily) |
| 2090 |
\e( ( ( [^()]++ | (?R) )* ) \e) |
set at a deeper level. |
| 2091 |
^ ^ |
.P |
| 2092 |
^ ^ |
If there are more than 15 capturing parentheses in a pattern, PCRE has to |
| 2093 |
.sp |
obtain extra memory to store data during a recursion, which it does by using |
| 2094 |
the string they capture is "ab(cd)ef", the contents of the top level |
\fBpcre_malloc\fP, freeing it via \fBpcre_free\fP afterwards. If no memory can |
| 2095 |
parentheses. If there are more than 15 capturing parentheses in a pattern, PCRE |
be obtained, the match fails with the PCRE_ERROR_NOMEMORY error. |
|
has to obtain extra memory to store data during a recursion, which it does by |
|
|
using \fBpcre_malloc\fP, freeing it via \fBpcre_free\fP afterwards. If no |
|
|
memory can be obtained, the match fails with the PCRE_ERROR_NOMEMORY error. |
|
| 2096 |
.P |
.P |
| 2097 |
Do not confuse the (?R) item with the condition (R), which tests for recursion. |
Do not confuse the (?R) item with the condition (R), which tests for recursion. |
| 2098 |
Consider this pattern, which matches text in angle brackets, allowing for |
Consider this pattern, which matches text in angle brackets, allowing for |
| 2203 |
is used, it does match "sense and responsibility" as well as the other two |
is used, it does match "sense and responsibility" as well as the other two |
| 2204 |
strings. Another example is given in the discussion of DEFINE above. |
strings. Another example is given in the discussion of DEFINE above. |
| 2205 |
.P |
.P |
| 2206 |
Like recursive subpatterns, a "subroutine" call is always treated as an atomic |
Like recursive subpatterns, a subroutine call is always treated as an atomic |
| 2207 |
group. That is, once it has matched some of the subject string, it is never |
group. That is, once it has matched some of the subject string, it is never |
| 2208 |
re-entered, even if it contains untried alternatives and there is a subsequent |
re-entered, even if it contains untried alternatives and there is a subsequent |
| 2209 |
matching failure. |
matching failure. Any capturing parentheses that are set during the subroutine |
| 2210 |
|
call revert to their previous values afterwards. |
| 2211 |
.P |
.P |
| 2212 |
When a subpattern is used as a subroutine, processing options such as |
When a subpattern is used as a subroutine, processing options such as |
| 2213 |
case-independence are fixed when the subpattern is defined. They cannot be |
case-independence are fixed when the subpattern is defined. They cannot be |
| 2291 |
failing negative assertion, they cause an error if encountered by |
failing negative assertion, they cause an error if encountered by |
| 2292 |
\fBpcre_dfa_exec()\fP. |
\fBpcre_dfa_exec()\fP. |
| 2293 |
.P |
.P |
| 2294 |
If any of these verbs are used in an assertion subpattern, their effect is |
If any of these verbs are used in an assertion or subroutine subpattern |
| 2295 |
confined to that subpattern; it does not extend to the surrounding pattern. |
(including recursive subpatterns), their effect is confined to that subpattern; |
| 2296 |
Note that assertion subpatterns are processed as anchored at the point where |
it does not extend to the surrounding pattern. Note that such subpatterns are |
| 2297 |
they are tested. |
processed as anchored at the point where they are tested. |
| 2298 |
.P |
.P |
| 2299 |
The new verbs make use of what was previously invalid syntax: an opening |
The new verbs make use of what was previously invalid syntax: an opening |
| 2300 |
parenthesis followed by an asterisk. In Perl, they are generally of the form |
parenthesis followed by an asterisk. In Perl, they are generally of the form |
| 2415 |
.rs |
.rs |
| 2416 |
.sp |
.sp |
| 2417 |
.nf |
.nf |
| 2418 |
Last updated: 04 October 2009 |
Last updated: 18 October 2009 |
| 2419 |
Copyright (c) 1997-2009 University of Cambridge. |
Copyright (c) 1997-2009 University of Cambridge. |
| 2420 |
.fi |
.fi |