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

Prepare this regular&hyphen;expression object with the specified `pattern`&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class STRING&gt;
int
prepare(
    STRING* errorMessage,
    size&lowbar;t* errorOffset,
    char const* pattern,
    int flags = 0,
    size&lowbar;t jitStackSize = 0)
requires bsl&colon;&colon;is&lowbar;same&lt;STRING, bsl&colon;&colon;string&gt;&colon;&colon;value
                            &verbar;&verbar; bsl&colon;&colon;is&lowbar;same&lt;STRING, std&colon;&colon;string&gt;&colon;&colon;value
&num;ifdef BSLS&lowbar;LIBRARYFEATURES&lowbar;HAS&lowbar;CPP17&lowbar;PMR&lowbar;STRING
                            &verbar;&verbar; bsl&colon;&colon;is&lowbar;same&lt;STRING, std&colon;&colon;pmr&colon;&colon;string&gt;&colon;&colon;value;
----

== Description

Prepare this regular&hyphen;expression object with the specified `pattern` and the optionally specified `flags`&period; `flags`, if supplied, should contain a bit&hyphen;wise or of the `k&lowbar;FLAG&lowbar;&ast;` constants defined by this class, which indicate additional configuration parameters for the regular expression&period; Optionally specify `jitStackSize`&period; If `flags` has the `k&lowbar;FLAG&lowbar;JIT` flag set, `jitStackSize` indicates the size of the allocated JIT stack to be used for this pattern&period; If `flags` has the `k&lowbar;FLAG&lowbar;JIT` bit set and `jitStackSize` is 0 (or not supplied), no memory will be allocated for the JIT stack and the program stack will be used as the JIT stack&period; If `flags` does not have `k&lowbar;FLAG&lowbar;JIT` set, or `isJitAvailable()` is `false`, the `jitStackSize` parameter, if supplied, is ignored&period; On success, put this object into the &quot;prepared&quot; state and return 0, with no effect on the specified `errorMessage` and `errorOffset`&period; Otherwise, (1) put this object into the &quot;unprepared&quot; state, (2) load `errorMessage` (if non&hyphen;null) with a string describing the error detected, (3) load `errorOffset` (if non&hyphen;null) with the offset in `pattern` at which the error was detected, and (4) return a non&hyphen;zero value&period; The behavior is undefined unless `flags` is 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; Note that the flag `k&lowbar;FLAG&lowbar;JIT` is ignored if `isJitAvailable()` is `false`&period;

== Return Value

0 on success, and a non&hyphen;zero value otherwise

== Parameters

[cols="1,4"]
|===
| Name| Description
| *errorMessage*
| optionally receives a compile&hyphen;error description
| *errorOffset*
| optionally receives the pattern offset of a compile error
| *pattern*
| null&hyphen;terminated regular&hyphen;expression pattern
| *flags*
| bit&hyphen;wise OR of `k&lowbar;FLAG&lowbar;&ast;` prepare options
| *jitStackSize*
| size of the JIT stack if `k&lowbar;FLAG&lowbar;JIT` is set
|===


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