int pcre_get_stringtable_entries(const pcre *
code,
const char *
name, char **
first, char **
last);
When a pattern is compiled with the PCRE_DUPNAMES option, names
for subpatterns are not required to be unique. (Duplicate names
are always allowed for subpatterns with the same number, created
by using the (?| feature. Indeed, if such subpatterns are named,
they are required to use the same names.)
Normally, patterns with duplicate names are such that in any one
match, only one of the named subpatterns participates. An example
is shown in the pcrepattern
documentation.
When duplicates are present, pcre_copy_named_substring()
and
pcre_get_named_substring()
return the first substring
corresponding to the given name that is set. If none are set,
PCRE_ERROR_NOSUBSTRING (-7) is returned; no data is returned. The
pcre_get_stringnumber()
function returns one of the numbers that
are associated with the name, but it is not defined which it is.
If you want to get full details of all captured substrings for a
given name, you must use the pcre_get_stringtable_entries()
function. The first argument is the compiled pattern, and the
second is the name. The third and fourth are pointers to
variables which are updated by the function. After it has run,
they point to the first and last entries in the name-to-number
table for the given name. The function itself returns the length
of each entry, or PCRE_ERROR_NOSUBSTRING (-7) if there are none.
The format of the table is described above in the section
entitled Information about a pattern above. Given all the
relevant entries for the name, you can extract each of their
numbers, and hence the captured data, if any.