[#BloombergLP-bdlpcre-RegEx-subpatternIndex]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlpcre.adoc[bdlpcre]::xref:BloombergLP/bdlpcre/RegEx.adoc[RegEx]::subpatternIndex
:relfileprefix: ../../../
:mrdocs:

Return the 1&hyphen;based index of the named sub&hyphen;pattern, or &hyphen;1&period;

== Synopsis

Declared in `&lt;bdlpcre&lowbar;regex&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
int
subpatternIndex(char const* name) const;
----

== Description

Return the 1&hyphen;based index of the sub&hyphen;pattern having the specified `name` in the pattern held by this regular&hyphen;expression object (`pattern()`)&semi; return &hyphen;1 if `pattern()` does not contain a sub&hyphen;pattern identified by `name` or `name` is not unique&period; The behavior is undefined unless `isPrepared() &equals;&equals; true`&period; Note that the returned value is intended to be used as an index into the `bsl&colon;&colon;vector&lt;bsl&colon;&colon;pair&lt;int, int&gt; &gt;` returned by `match`&period; Also note that the function `namedSubpatterns` can be used to find the sub&hyphen;pattern index when there are duplicate named sub&hyphen;patterns&period;

== Return Value

1&hyphen;based sub&hyphen;pattern index, or &hyphen;1 if not found or not unique

== Parameters

[cols="1,4"]
|===
| Name| Description
| *name*
| null&hyphen;terminated name of the sub&hyphen;pattern
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
