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

This class provides a mechanism for compiling and matching regular expressions&period; A regular expression approximately compatible with Perl 5&period;10 is compiled with the `prepare` method&period; Subsequently, strings are matched against the compiled (prepared) pattern using the overloaded `match` and `matchRaw` methods&period; Note that the underlying implementation uses the open&hyphen;source Perl Compatible Regular Expressions (PCRE2) library that was developed at the University of Cambridge (`http&colon;&sol;&sol;www&period;pcre&period;org&sol;`)&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class RegEx;
----

== Enums

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlpcre/RegEx/_04enum-07.adoc[`Unnamed enum`] 
| Flags that may be supplied to `prepare` to affect matching behavior&period;
| xref:BloombergLP/bdlpcre/RegEx/_04enum-0e.adoc[`Unnamed enum`] 
| Flags that may be supplied to `replace` to affect replacement behavior&period;
| xref:BloombergLP/bdlpcre/RegEx/_04enum-02.adoc[`Unnamed enum`] 
| Status codes distinguishing among results of match operations&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlpcre/RegEx/2constructor.adoc[`RegEx`]         [.small]#[constructor]#
| Create a regular&hyphen;expression object in the &quot;unprepared&quot; state&period; Optionally specify a `basicAllocator` used to supply memory&period; The alignment strategy of the allocator must be &quot;maximum&quot; or &quot;natural&quot;&period; If `basicAllocator` is 0, the currently installed default allocator is used&period;
| xref:BloombergLP/bdlpcre/RegEx/2destructor.adoc[`&#126;RegEx`] [.small]#[destructor]#
| Destroy this regular&hyphen;expression object&period;
| xref:BloombergLP/bdlpcre/RegEx/clear.adoc[`clear`] 
| Free resources used by this regular&hyphen;expression object and put this object into the &quot;unprepared&quot; state&period; This method has no effect if this object is already in the &quot;unprepared&quot; state&period;
| xref:BloombergLP/bdlpcre/RegEx/depthLimit.adoc[`depthLimit`] 
| Return the evaluation recursion depth limit for this regular&hyphen;expression object&period;
| xref:BloombergLP/bdlpcre/RegEx/flags.adoc[`flags`] 
| Return the flags that were supplied to the most recent successful call to the `prepare` method of this regular&hyphen;expression object&period; The behavior is undefined unless `isPrepared() &equals;&equals; true`&period; Note that the returned value will be the bit&hyphen;wise inclusive&hyphen;or of 0 or more of the following values&colon; &grave; k&lowbar;FLAG&lowbar;CASELESS k&lowbar;FLAG&lowbar;DOTMATCHESALL k&lowbar;FLAG&lowbar;MULTILINE k&lowbar;FLAG&lowbar;UTF8 k&lowbar;FLAG&lowbar;JIT k&lowbar;FLAG&lowbar;DUPNAMES &grave; Also note that `k&lowbar;FLAG&lowbar;JIT` is ignored, but still returned by this method, if `isJitAvailable()` is `false`&period;
| xref:BloombergLP/bdlpcre/RegEx/isPrepared.adoc[`isPrepared`] 
| Return `true` if this regular&hyphen;expression object is in the &quot;prepared&quot; state, and `false` otherwise&period;
| xref:BloombergLP/bdlpcre/RegEx/jitStackSize.adoc[`jitStackSize`] 
| Return the size of the dynamically allocated JIT stack if it has been specified explicitly with the `prepare` method&period; Return 0 if a zero `jitStackSize` value was passed to the `prepare` method (or not supplied at all) or if `isPrepared()` is `false`&period;
| xref:BloombergLP/bdlpcre/RegEx/match-08.adoc[`match`] 
| `match` overloads
| xref:BloombergLP/bdlpcre/RegEx/matchRaw-088.adoc[`matchRaw`] 
| `matchRaw` overloads
| xref:BloombergLP/bdlpcre/RegEx/namedSubpatterns-05.adoc[`namedSubpatterns`] 
| `namedSubpatterns` overloads
| xref:BloombergLP/bdlpcre/RegEx/numSubpatterns.adoc[`numSubpatterns`] 
| Return the number of sub&hyphen;patterns in the pattern held by this regular&hyphen;expression object (`pattern()`)&period; The behavior is undefined unless `isPrepared() &equals;&equals; true`&period;
| xref:BloombergLP/bdlpcre/RegEx/pattern.adoc[`pattern`] 
| Return a reference to the non&hyphen;modifiable pattern held by this regular&hyphen;expression object&period; The behavior is undefined unless `isPrepared() &equals;&equals; true`&period;
| xref:BloombergLP/bdlpcre/RegEx/prepare-08.adoc[`prepare`] 
| `prepare` overloads
| xref:BloombergLP/bdlpcre/RegEx/replace-05.adoc[`replace`] 
| `replace` overloads
| xref:BloombergLP/bdlpcre/RegEx/replaceRaw-0fe.adoc[`replaceRaw`] 
| `replaceRaw` overloads
| xref:BloombergLP/bdlpcre/RegEx/setDepthLimit.adoc[`setDepthLimit`] 
| Set the evaluation recursion depth limit for this regular&hyphen;expression object to the specified `depthLimit`&period; Return the previous depth limit&period;
| xref:BloombergLP/bdlpcre/RegEx/subpatternIndex.adoc[`subpatternIndex`] 
| 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;
| xref:BloombergLP/bdlpcre/RegEx/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;RegEx, UsesBslmaAllocator&gt;`] 
| Declare that this type uses a `bslma` allocator&period;
|===


== Static Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlpcre/RegEx/defaultDepthLimit.adoc[`defaultDepthLimit`] 
| Return the process&hyphen;wide default evaluation recursion depth limit&period;
| xref:BloombergLP/bdlpcre/RegEx/isJitAvailable.adoc[`isJitAvailable`] 
| Return `true` if just&hyphen;in&hyphen;time compiling optimization is supported by current hardware platform and `false` otherwise&period; Note that JIT support is limited to the following hardware platforms&colon; &grave; ARM 32&hyphen;bit (v5, v7, and Thumb2) ARM 64&hyphen;bit Intel x86 32&hyphen;bit and 64&hyphen;bit MIPS 32&hyphen;bit and 64&hyphen;bit Power PC 32&hyphen;bit and 64&hyphen;bit SPARC 32&hyphen;bit &grave;
| xref:BloombergLP/bdlpcre/RegEx/setDefaultDepthLimit.adoc[`setDefaultDepthLimit`] 
| Set the process&hyphen;wide default evaluation recursion depth limit to the specified `depthLimit`&period; Return the previous depth limit&period;
|===


== Static Data Members

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlpcre/RegEx/k_INVALID_OFFSET.adoc[`k&lowbar;INVALID&lowbar;OFFSET`] 
| Value used to denote an invalid offset for match methods returning pairs&period;
|===



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