BloombergLP::bdlpcre::RegEx

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>

class RegEx;

Enums

NameDescription
Unnamed enum Flags that may be supplied to prepare to affect matching behavior.
Unnamed enum Flags that may be supplied to replace to affect replacement behavior.
Unnamed enum Status codes distinguishing among results of match operations.

Member Functions

NameDescription
RegEx [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.
~RegEx [destructor]Destroy this regular-expression object.
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.
depthLimit Return the evaluation recursion depth limit for this regular-expression object.
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.
isPrepared Return true if this regular-expression object is in the "prepared" state, and false otherwise.
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.
match match overloads
matchRaw matchRaw overloads
namedSubpatterns namedSubpatterns overloads
numSubpatterns Return the number of sub-patterns in the pattern held by this regular-expression object (pattern()). The behavior is undefined unless isPrepared() == true.
pattern Return a reference to the non-modifiable pattern held by this regular-expression object. The behavior is undefined unless isPrepared() == true.
prepare prepare overloads
replace replace overloads
replaceRaw replaceRaw overloads
setDepthLimit Set the evaluation recursion depth limit for this regular-expression object to the specified depthLimit. Return the previous depth limit.
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.
operator BloombergLP::bslmf::NestedTraitDeclaration<RegEx, UsesBslmaAllocator> Declare that this type uses a bslma allocator.

Static Member Functions

NameDescription
defaultDepthLimit Return the process-wide default evaluation recursion depth limit.
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 `
setDefaultDepthLimit Set the process-wide default evaluation recursion depth limit to the specified depthLimit. Return the previous depth limit.

Static Data Members

NameDescription
k_INVALID_OFFSET Value used to denote an invalid offset for match methods returning pairs.