[#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. A regular expression approximately compatible with Perl 5.10 is compiled with the `prepare` method. Subsequently, strings are matched against the compiled (prepared) pattern using the overloaded `match` and `matchRaw` methods. Note that the underlying implementation uses the open‐source Perl Compatible Regular Expressions (PCRE2) library that was developed at the University of Cambridge (`http://www.pcre.org/`). == Synopsis Declared in `<bdlpcre_regex.h>` [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. | xref:BloombergLP/bdlpcre/RegEx/_04enum-0e.adoc[`Unnamed enum`] | Flags that may be supplied to `replace` to affect replacement behavior. | xref:BloombergLP/bdlpcre/RegEx/_04enum-02.adoc[`Unnamed enum`] | Status codes distinguishing among results of match operations. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlpcre/RegEx/2constructor.adoc[`RegEx`] [.small]#[constructor]# | Create a regular‐expression object in the "unprepared" state. Optionally specify a `basicAllocator` used to supply memory. The alignment strategy of the allocator must be "maximum" or "natural". If `basicAllocator` is 0, the currently installed default allocator is used. | xref:BloombergLP/bdlpcre/RegEx/2destructor.adoc[`~RegEx`] [.small]#[destructor]# | Destroy this regular‐expression object. | xref:BloombergLP/bdlpcre/RegEx/clear.adoc[`clear`] | Free resources used by this regular‐expression object and put this object into the "unprepared" state. This method has no effect if this object is already in the "unprepared" state. | xref:BloombergLP/bdlpcre/RegEx/depthLimit.adoc[`depthLimit`] | Return the evaluation recursion depth limit for this regular‐expression object. | 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‐expression object. The behavior is undefined unless `isPrepared() == true`. Note that the returned value will be the bit‐wise inclusive‐or of 0 or more of the following values: ` k_FLAG_CASELESS k_FLAG_DOTMATCHESALL k_FLAG_MULTILINE k_FLAG_UTF8 k_FLAG_JIT k_FLAG_DUPNAMES ` Also note that `k_FLAG_JIT` is ignored, but still returned by this method, if `isJitAvailable()` is `false`. | xref:BloombergLP/bdlpcre/RegEx/isPrepared.adoc[`isPrepared`] | Return `true` if this regular‐expression object is in the "prepared" state, and `false` otherwise. | 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. Return 0 if a zero `jitStackSize` value was passed to the `prepare` method (or not supplied at all) or if `isPrepared()` is `false`. | 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‐patterns in the pattern held by this regular‐expression object (`pattern()`). The behavior is undefined unless `isPrepared() == true`. | xref:BloombergLP/bdlpcre/RegEx/pattern.adoc[`pattern`] | Return a reference to the non‐modifiable pattern held by this regular‐expression object. The behavior is undefined unless `isPrepared() == true`. | 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‐expression object to the specified `depthLimit`. Return the previous depth limit. | xref:BloombergLP/bdlpcre/RegEx/subpatternIndex.adoc[`subpatternIndex`] | Return the 1‐based index of the sub‐pattern having the specified `name` in the pattern held by this regular‐expression object (`pattern()`); return ‐1 if `pattern()` does not contain a sub‐pattern identified by `name` or `name` is not unique. The behavior is undefined unless `isPrepared() == true`. Note that the returned value is intended to be used as an index into the `bsl::vector<bsl::pair<int, int> >` returned by `match`. Also note that the function `namedSubpatterns` can be used to find the sub‐pattern index when there are duplicate named sub‐patterns. | xref:BloombergLP/bdlpcre/RegEx/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration<RegEx, UsesBslmaAllocator>`] | Declare that this type uses a `bslma` allocator. |=== == Static Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlpcre/RegEx/defaultDepthLimit.adoc[`defaultDepthLimit`] | Return the process‐wide default evaluation recursion depth limit. | xref:BloombergLP/bdlpcre/RegEx/isJitAvailable.adoc[`isJitAvailable`] | Return `true` if just‐in‐time compiling optimization is supported by current hardware platform and `false` otherwise. Note that JIT support is limited to the following hardware platforms: ` ARM 32‐bit (v5, v7, and Thumb2) ARM 64‐bit Intel x86 32‐bit and 64‐bit MIPS 32‐bit and 64‐bit Power PC 32‐bit and 64‐bit SPARC 32‐bit ` | xref:BloombergLP/bdlpcre/RegEx/setDefaultDepthLimit.adoc[`setDefaultDepthLimit`] | Set the process‐wide default evaluation recursion depth limit to the specified `depthLimit`. Return the previous depth limit. |=== == Static Data Members [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlpcre/RegEx/k_INVALID_OFFSET.adoc[`k_INVALID_OFFSET`] | Value used to denote an invalid offset for match methods returning pairs. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#