| 1012 |
length of the longest name. PCRE_INFO_NAMETABLE returns a pointer to the first |
length of the longest name. PCRE_INFO_NAMETABLE returns a pointer to the first |
| 1013 |
entry of the table (a pointer to \fBchar\fP). The first two bytes of each entry |
entry of the table (a pointer to \fBchar\fP). The first two bytes of each entry |
| 1014 |
are the number of the capturing parenthesis, most significant byte first. The |
are the number of the capturing parenthesis, most significant byte first. The |
| 1015 |
rest of the entry is the corresponding name, zero terminated. The names are in |
rest of the entry is the corresponding name, zero terminated. |
| 1016 |
alphabetical order. When PCRE_DUPNAMES is set, duplicate names are in order of |
.P |
| 1017 |
their parentheses numbers. For example, consider the following pattern (assume |
The names are in alphabetical order. Duplicate names may appear if (?| is used |
| 1018 |
PCRE_EXTENDED is set, so white space - including newlines - is ignored): |
to create multiple groups with the same number, as described in the |
| 1019 |
|
.\" HTML <a href="pcrepattern.html#dupsubpatternnumber"> |
| 1020 |
|
.\" </a> |
| 1021 |
|
section on duplicate subpattern numbers |
| 1022 |
|
.\" |
| 1023 |
|
in the |
| 1024 |
|
.\" HREF |
| 1025 |
|
\fBpcrepattern\fP |
| 1026 |
|
.\" |
| 1027 |
|
page. Duplicate names for subpatterns with different numbers are permitted only |
| 1028 |
|
if PCRE_DUPNAMES is set. In all cases of duplicate names, they appear in the |
| 1029 |
|
table in the order in which they were found in the pattern. In the absence of |
| 1030 |
|
(?| this is the order of increasing number; when (?| is used this is not |
| 1031 |
|
necessarily the case because later subpatterns may have lower numbers. |
| 1032 |
|
.P |
| 1033 |
|
As a simple example of the name/number table, consider the following pattern |
| 1034 |
|
(assume PCRE_EXTENDED is set, so white space - including newlines - is |
| 1035 |
|
ignored): |
| 1036 |
.sp |
.sp |
| 1037 |
.\" JOIN |
.\" JOIN |
| 1038 |
(?<date> (?<year>(\ed\ed)?\ed\ed) - |
(?<date> (?<year>(\ed\ed)?\ed\ed) - |
| 1806 |
appropriate. \fBNOTE:\fP If PCRE_DUPNAMES is set and there are duplicate names, |
appropriate. \fBNOTE:\fP If PCRE_DUPNAMES is set and there are duplicate names, |
| 1807 |
the behaviour may not be what you want (see the next section). |
the behaviour may not be what you want (see the next section). |
| 1808 |
.P |
.P |
| 1809 |
\fBWarning:\fP If the pattern uses the "(?|" feature to set up multiple |
\fBWarning:\fP If the pattern uses the (?| feature to set up multiple |
| 1810 |
subpatterns with the same number, you cannot use names to distinguish them, |
subpatterns with the same number, as described in the |
| 1811 |
because names are not included in the compiled code. The matching process uses |
.\" HTML <a href="pcrepattern.html#dupsubpatternnumber"> |
| 1812 |
only numbers. |
.\" </a> |
| 1813 |
|
section on duplicate subpattern numbers |
| 1814 |
|
.\" |
| 1815 |
|
in the |
| 1816 |
|
.\" HREF |
| 1817 |
|
\fBpcrepattern\fP |
| 1818 |
|
.\" |
| 1819 |
|
page, you cannot use names to distinguish the different subpatterns, because |
| 1820 |
|
names are not included in the compiled code. The matching process uses only |
| 1821 |
|
numbers. For this reason, the use of different names for subpatterns of the |
| 1822 |
|
same number causes an error at compile time. |
| 1823 |
. |
. |
| 1824 |
.SH "DUPLICATE SUBPATTERN NAMES" |
.SH "DUPLICATE SUBPATTERN NAMES" |
| 1825 |
.rs |
.rs |
| 1829 |
.B const char *\fIname\fP, char **\fIfirst\fP, char **\fIlast\fP); |
.B const char *\fIname\fP, char **\fIfirst\fP, char **\fIlast\fP); |
| 1830 |
.PP |
.PP |
| 1831 |
When a pattern is compiled with the PCRE_DUPNAMES option, names for subpatterns |
When a pattern is compiled with the PCRE_DUPNAMES option, names for subpatterns |
| 1832 |
are not required to be unique. Normally, patterns with duplicate names are such |
are not required to be unique. (Duplicate names are always allowed for |
| 1833 |
that in any one match, only one of the named subpatterns participates. An |
subpatterns with the same number, created by using the (?| feature. Indeed, if |
| 1834 |
example is shown in the |
such subpatterns are named, they are required to use the same names.) |
| 1835 |
|
.P |
| 1836 |
|
Normally, patterns with duplicate names are such that in any one match, only |
| 1837 |
|
one of the named subpatterns participates. An example is shown in the |
| 1838 |
.\" HREF |
.\" HREF |
| 1839 |
\fBpcrepattern\fP |
\fBpcrepattern\fP |
| 1840 |
.\" |
.\" |
| 2075 |
.rs |
.rs |
| 2076 |
.sp |
.sp |
| 2077 |
.nf |
.nf |
| 2078 |
Last updated: 29 September 2009 |
Last updated: 03 October 2009 |
| 2079 |
Copyright (c) 1997-2009 University of Cambridge. |
Copyright (c) 1997-2009 University of Cambridge. |
| 2080 |
.fi |
.fi |