<!DOCTYPE html><htmllang="en"><head><metacharset="utf-8"><metaname="viewport"content="width=device-width, initial-scale=1.0"><metaname="generator"content="rustdoc"><metaname="description"content="A regex matcher that works by composing several other regex matchers automatically."><title>Regex in regex_automata::meta - Rust</title><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><linkrel="stylesheet"href="../../static.files/normalize-76eba96aa4d2e634.css"><linkrel="stylesheet"href="../../static.files/rustdoc-ac92e1bbe349e143.css"><metaname="rustdoc-vars"data-root-path="../../"data-static-root-path="../../static.files/"data-current-crate="regex_automata"data-themes=""data-resource-suffix=""data-rustdoc-version="1.76.0 (07dca489a 2024-02-04)"data-channel="1.76.0"data-search-js="search-2b6ce74ff89ae146.js"data-settings-js="settings-4313503d2e1961c2.js"><scriptsrc="../../static.files/storage-f2adc0d6ca4d09fb.js"></script><scriptdefersrc="sidebar-items.js"></script><scriptdefersrc="../../static.files/main-305769736d49e732.js"></script><noscript><linkrel="stylesheet"href="../../static.files/noscript-feafe1bb7466e4bd.css"></noscript><linkrel="alternate icon"type="image/png"href="../../static.files/favicon-16x16-8b506e7a72182f1c.png"><linkrel="alternate icon"type="image/png"href="../../static.files/favicon-32x32-422f7d1d52889060.png"><linkrel="icon"type="image/svg+xml"href="../../static.files/favicon-2c020d218678b618.svg"></head><bodyclass="rustdoc struct"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><navclass="mobile-topbar"><buttonclass="sidebar-menu-toggle">☰</button></nav><navclass="sidebar"><divclass="sidebar-crate"><h2><ahref="../../regex_automata/index.html">regex_automata</a><spanclass="version">0.4.5</span></h2></div><h2class="location"><ahref="#">Regex</a></h2><divclass="sidebar-elems"><section><h3><ahref="#implementations">Methods</a></h3><ulclass="block method"><li><ahref="#method.builder">builder</a></li><li><ahref="#method.captures">captures</a></li><li><ahref="#method.captures_iter">captures_iter</a></li><li><ahref="#method.captures_len">captures_len</a></li><li><ahref="#method.config">config</a></li><li><ahref="#method.create_cache">create_cache</a></li><li><ahref="#method.create_captures">create_captures</a></li><li><ahref="#method.find">find</a></li><li><ahref="#method.find_iter">find_iter</a></li><li><ahref="#method.get_config">get_config</a></li><li><ahref="#method.group_info">group_info</a></li><li><ahref="#method.is_accelerated">is_accelerated</a></li><li><ahref="#method.is_match">is_match</a></li><li><ahref="#method.memory_usage">memory_usage</a></li><li><ahref="#method.new">new</a></li><li><ahref="#method.new_many">new_many</a></li><li><ahref="#method.pattern_len">pattern_len</a></li><li><ahref="#method.search">search</a></li><li><ahref="#method.search_captures">search_captures</a></li><li><ahref="#method.search_captures_with">search_captures_with</a></li><li><ahref="#method.search_half">search_half</a></li><li><ahref="#method.search_half_with">search_half_with</a></li><li><ahref="#method.search_slots">search_slots</a></li><li><ahref="#method.search_slots_with">search_slots_with</a></li><li><ahref="#method.search_with">search_with</a></li><li><ahref="#method.split">split</a></li><li><ahref="#method.splitn">splitn</a></li><li><ahref="#method.
<main><divclass="width-limiter"><navclass="sub"><formclass="search-form"><span></span><divid="sidebar-button"tabindex="-1"><ahref="../../regex_automata/all.html"title="show sidebar"></a></div><inputclass="search-input"name="search"aria-label="Run search in the documentation"autocomplete="off"spellcheck="false"placeholder="Click or press ‘S’ to search, ‘?’ for more options…"type="search"><divid="help-button"tabindex="-1"><ahref="../../help.html"title="help">?</a></div><divid="settings-menu"tabindex="-1"><ahref="../../settings.html"title="settings"><imgwidth="22"height="22"alt="Change settings"src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><sectionid="main-content"class="content"><divclass="main-heading"><h1>Struct <ahref="../index.html">regex_automata</a>::<wbr><ahref="index.html">meta</a>::<wbr><aclass="struct"href="#">Regex</a><buttonid="copy-path"title="Copy item path to clipboard"><imgsrc="../../static.files/clipboard-7571035ce49a181d.svg"width="19"height="18"alt="Copy item path"></button></h1><spanclass="out-of-band"><aclass="src"href="../../src/regex_automata/meta/regex.rs.html#235-252">source</a> · <buttonid="toggle-all-docs"title="collapse all docs">[<span>−</span>]</button></span></div><preclass="rust item-decl"><code>pub struct Regex { <spanclass="comment">/* private fields */</span> }</code></pre><detailsclass="toggle top-doc"open><summaryclass="hideme"><span>Expand description</span></summary><divclass="docblock"><p>A regex matcher that works by composing several other regex matchers
automatically.</p>
<p>In effect, a meta regex papers over a lot of the quirks or performance
problems in each of the regex engines in this crate. Its goal is to provide
an infallible and simple API that “just does the right thing” in the common
case.</p>
<p>A meta regex is the implementation of a <code>Regex</code> in the <code>regex</code> crate.
Indeed, the <code>regex</code> crate API is essentially just a light wrapper over
this type. This includes the <code>regex</code> crate’s <code>RegexSet</code> API!</p>
<p>This is called a “meta” matcher precisely because it uses other regex
matchers to provide a convenient high level regex API. Here are some
examples of how other regex matchers are composed:</p>
<ul>
<li>When calling <ahref="struct.Regex.html#method.captures"title="method regex_automata::meta::Regex::captures"><code>Regex::captures</code></a>, instead of immediately
running a slower but more capable regex engine like the
<ahref="../nfa/thompson/pikevm/struct.PikeVM.html"title="struct regex_automata::nfa::thompson::pikevm::PikeVM"><code>PikeVM</code></a>, the meta regex engine
will usually first look for the bounds of a match with a higher throughput
is a slower engine like <code>PikeVM</code> used to find the matching span for each
capture group.</li>
<li>While higher throughout engines like the lazy DFA cannot handle
Unicode word boundaries in general, they can still be used on pure ASCII
haystacks by pretending that Unicode word boundaries are just plain ASCII
word boundaries. However, if a haystack is not ASCII, the meta regex engine
will automatically switch to a (possibly slower) regex engine that supports
Unicode word boundaries in general.</li>
<li>In some cases where a regex pattern is just a simple literal or a small
set of literals, an actual regex engine won’t be used at all. Instead,
substring or multi-substring search algorithms will be employed.</li>
</ul>
<p>There are many other forms of composition happening too, but the above
should give a general idea. In particular, it may perhaps be surprising
that <em>multiple</em> regex engines might get executed for a single search. That
is, the decision of what regex engine to use is not <em>just</em> based on the
pattern, but also based on the dynamic execution of the search itself.</p>
<p>The primary reason for this composition is performance. The fundamental
tension is that the faster engines tend to be less capable, and the more
capable engines tend to be slower.</p>
<p>Note that the forms of composition that are allowed are determined by
compile time crate features and configuration. For example, if the <code>hybrid</code>
feature isn’t enabled, or if <ahref="struct.Config.html#method.hybrid"title="method regex_automata::meta::Config::hybrid"><code>Config::hybrid</code></a> has been disabled, then the
meta regex engine will never use a lazy DFA.</p>
<h2id="synchronization-and-cloning"><ahref="#synchronization-and-cloning">Synchronization and cloning</a></h2>
<p>Most of the regex engines in this crate require some kind of mutable
“scratch” space to read and write from while performing a search. Since
a meta regex composes these regex engines, a meta regex also requires
mutable scratch space. This scratch space is called a <ahref="struct.Cache.html"title="struct regex_automata::meta::Cache"><code>Cache</code></a>.</p>
<p>Most regex engines <em>also</em> usually have a read-only component, typically
a <ahref="../nfa/thompson/struct.NFA.html"title="struct regex_automata::nfa::thompson::NFA">Thompson <code>NFA</code></a>.</p>
<p>In order to make the <code>Regex</code> API convenient, most of the routines hide
the fact that a <code>Cache</code> is needed at all. To achieve this, a <ahref="../util/pool/struct.Pool.html"title="struct regex_automata::util::pool::Pool">memory
pool</a> is used internally to retrieve <code>Cache</code>
values in a thread safe way that also permits reuse. This in turn implies
that every such search call requires some form of synchronization. Usually
this synchronization is fast enough to not notice, but in some cases, it
can be a bottleneck. This typically occurs when all of the following are
true:</p>
<ul>
<li>The same <code>Regex</code> is shared across multiple threads simultaneously,
usually via a <ahref="../util/lazy/struct.Lazy.html"title="struct regex_automata::util::lazy::Lazy"><code>util::lazy::Lazy</code></a> or something
similar from the <code>once_cell</code> or <code>lazy_static</code> crates.</li>
<li>The primary unit of work in each thread is a regex search.</li>
<li>Searches are run on very short haystacks.</li>
</ul>
<p>This particular case can lead to high contention on the pool used by a
<code>Regex</code> internally, which can in turn increase latency to a noticeable
effect. This cost can be mitigated in one of the following ways:</p>
<ul>
<li>Use a distinct copy of a <code>Regex</code> in each thread, usually by cloning it.
Cloning a <code>Regex</code><em>does not</em> do a deep copy of its read-only component.
But it does lead to each <code>Regex</code> having its own memory pool, which in
turn eliminates the problem of contention. In general, this technique should
not result in any additional memory usage when compared to sharing the same
<code>Regex</code> across multiple threads simultaneously.</li>
<li>Use lower level APIs, like <ahref="struct.Regex.html#method.search_with"title="method regex_automata::meta::Regex::search_with"><code>Regex::search_with</code></a>, which permit passing
a <code>Cache</code> explicitly. In this case, it is up to you to determine how best
to provide a <code>Cache</code>. For example, you might put a <code>Cache</code> in thread-local
storage if your use case allows for it.</li>
</ul>
<p>Overall, this is an issue that happens rarely in practice, but it can
happen.</p>
<h2id="warning-spin-locks-may-be-used-in-alloc-only-mode"><ahref="#warning-spin-locks-may-be-used-in-alloc-only-mode">Warning: spin-locks may be used in alloc-only mode</a></h2>
<p>When this crate is built without the <code>std</code> feature and the high level APIs
on a <code>Regex</code> are used, then a spin-lock will be used to synchronize access
to an internal pool of <code>Cache</code> values. This may be undesirable because
a spin-lock is <ahref="https://matklad.github.io/2020/01/02/spinlocks-considered-harmful.html">effectively impossible to implement correctly in user
space</a>. That is, more concretely, the spin-lock could
result in a deadlock.</p>
<p>If one wants to avoid the use of spin-locks when the <code>std</code> feature is
disabled, then you must use APIs that accept a <code>Cache</code> value explicitly.
For example, <ahref="struct.Regex.html#method.search_with"title="method regex_automata::meta::Regex::search_with"><code>Regex::search_with</code></a>.</p>
<p>This example shows how to use <ahref="../struct.Input.html#method.anchored"title="method regex_automata::Input::anchored"><code>Input::anchored</code></a> to run an anchored
search, even when the regex pattern itself isn’t anchored. An anchored
search guarantees that if a match is found, then the start offset of the
match corresponds to the offset at which the search was started.</p>
<p>This example shows how to use <ahref="../struct.Input.html#method.earliest"title="method regex_automata::Input::earliest"><code>Input::earliest</code></a> to run a search that
might stop before finding the typical leftmost match.</p>
</div></details><h2id="implementations"class="section-header">Implementations<ahref="#implementations"class="anchor">§</a></h2><divid="implementations-list"><detailsclass="toggle implementors-toggle"open><summary><sectionid="impl-Regex"class="impl"><aclass="src rightside"href="../../src/regex_automata/meta/regex.rs.html#281-450">source</a><ahref="#impl-Regex"class="anchor">§</a><h3class="code-header">impl <aclass="struct"href="struct.Regex.html"title="struct regex_automata::meta::Regex">Regex</a></h3></section></summary><divclass="docblock"><p>Convenience constructors for a <code>Regex</code> using the default configuration.</p>
</div><divclass="impl-items"><detailsclass="toggle method-toggle"open><summary><sectionid="method.new"class="method"><aclass="src rightside"href="../../src/regex_automata/meta/regex.rs.html#302-304">source</a><h4class="code-header">pub fn <ahref="#method.new"class="fn">new</a>(pattern: &<aclass="primitive"href="https://doc.rust-lang.org/1.76.0/std/primitive.str.html">str</a>) -><aclass="enum"href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html"title="enum core::result::Result">Result</a><<aclass="struct"href="struct.Regex.html"title="struct regex_automata::meta::Regex">Regex</a>, <aclass="struct"href="struct.BuildError.html"title="struct regex_automata::meta::BuildError">BuildError</a>></h4></section></summary><divclass="docblock"><p>Builds a <code>Regex</code> from a single pattern string using the default
configuration.</p>
<p>If there was a problem parsing the pattern or a problem turning it into
a regex matcher, then an error is returned.</p>
<p>If you want to change the configuration of a <code>Regex</code>, use a <ahref="struct.Builder.html"title="struct regex_automata::meta::Builder"><code>Builder</code></a>
with a <ahref="struct.Config.html"title="struct regex_automata::meta::Config"><code>Config</code></a>.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.new_many"class="method"><aclass="src rightside"href="../../src/regex_automata/meta/regex.rs.html#393-397">source</a><h4class="code-header">pub fn <ahref="#method.new_many"class="fn">new_many</a><P: <aclass="trait"href="https://doc.rust-lang.org/1.76.0/core/convert/trait.AsRef.html"title="trait core::convert::AsRef">AsRef</a><<aclass="primitive"href="https://doc.rust-lang.org/1.76.0/std/primitive.str.html">str</a>>>(patterns: &<aclass="primitive"href="https://doc.rust-lang.org/1.76.0/std/primitive.slice.html">[P]</a>) -><aclass="enum"href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html"title="enum core::result::Result">Result</a><<aclass="struct"href="struct.Regex.html"title="struct regex_automata::meta::Regex">Regex</a>, <aclass="struct"href="struct.BuildError.html"title="struct regex_automata::meta::BuildError">BuildError</a>></h4></section></summary><divclass="docblock"><p>Builds a <code>Regex</code> from many pattern strings using the default
configuration.</p>
<p>If there was a problem parsing any of the patterns or a problem turning
them into a regex matcher, then an error is returned.</p>
<p>If you want to change the configuration of a <code>Regex</code>, use a <ahref="struct.Builder.html"title="struct regex_automata::meta::Builder"><code>Builder</code></a>
with a <ahref="struct.Config.html"title="struct regex_automata::meta::Config"><code>Config</code></a>.</p>
but then you need to ask whether capture group matched to determine
which branch in the regex matched, and thus, which token the match
corresponds to. In contrast, the above example includes the pattern ID
in the match. There’s no need to use capture groups at all.</p>
<h5id="example-finding-the-pattern-that-caused-an-error"><ahref="#example-finding-the-pattern-that-caused-an-error">Example: finding the pattern that caused an error</a></h5>
<p>When a syntax error occurs, it is possible to ask which pattern
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.config"class="method"><aclass="src rightside"href="../../src/regex_automata/meta/regex.rs.html#421-423">source</a><h4class="code-header">pub fn <ahref="#method.config"class="fn">config</a>() -><aclass="struct"href="struct.Config.html"title="struct regex_automata::meta::Config">Config</a></h4></section></summary><divclass="docblock"><p>Return a default configuration for a <code>Regex</code>.</p>
<p>This is a convenience routine to avoid needing to import the <ahref="struct.Config.html"title="struct regex_automata::meta::Config"><code>Config</code></a>
type when customizing the construction of a <code>Regex</code>.</p>
<h5id="example-lower-the-nfa-size-limit"><ahref="#example-lower-the-nfa-size-limit">Example: lower the NFA size limit</a></h5>
<p>In some cases, the default size limit might be too big. The size limit
can be lowered, which will prevent large regex patterns from compiling.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.builder"class="method"><aclass="src rightside"href="../../src/regex_automata/meta/regex.rs.html#447-449">source</a><h4class="code-header">pub fn <ahref="#method.builder"class="fn">builder</a>() -><aclass="struct"href="struct.Builder.html"title="struct regex_automata::meta::Builder">Builder</a></h4></section></summary><divclass="docblock"><p>Return a builder for configuring the construction of a <code>Regex</code>.</p>
<p>This is a convenience routine to avoid needing to import the
<ahref="struct.Builder.html"title="struct regex_automata::meta::Builder"><code>Builder</code></a> type in common cases.</p>
<h5id="example-change-the-line-terminator-1"><ahref="#example-change-the-line-terminator-1">Example: change the line terminator</a></h5>
<p>This example shows how to enable multi-line mode by default and change
</div></details></div></details><detailsclass="toggle implementors-toggle"open><summary><sectionid="impl-Regex-1"class="impl"><aclass="src rightside"href="../../src/regex_automata/meta/regex.rs.html#453-895">source</a><ahref="#impl-Regex-1"class="anchor">§</a><h3class="code-header">impl <aclass="struct"href="struct.Regex.html"title="struct regex_automata::meta::Regex">Regex</a></h3></section></summary><divclass="docblock"><p>High level convenience routines for using a regex to search a haystack.</p>
</div><divclass="impl-items"><detailsclass="toggle method-toggle"open><summary><sectionid="method.is_match"class="method"><aclass="src rightside"href="../../src/regex_automata/meta/regex.rs.html#530-540">source</a><h4class="code-header">pub fn <ahref="#method.is_match"class="fn">is_match</a><'h, I: <aclass="trait"href="https://doc.rust-lang.org/1.76.0/core/convert/trait.Into.html"title="trait core::convert::Into">Into</a><<aclass="struct"href="../struct.Input.html"title="struct regex_automata::Input">Input</a><'h>>>(&self, input: I) -><aclass="primitive"href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a></h4></section></summary><divclass="docblock"><p>Returns true if and only if this regex matches the given haystack.</p>
<p>This routine may short circuit if it knows that scanning future input
will never lead to a different result. (Consider how this might make
a difference given the regex <code>a+</code> on the haystack <code>aaaaaaaaaaaaaaa</code>.
This routine <em>may</em> stop after it sees the first <code>a</code>, but routines like
<code>find</code> need to continue searching because <code>+</code> is greedy by default.)</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.find"class="method"><aclass="src rightside"href="../../src/regex_automata/meta/regex.rs.html#556-558">source</a><h4class="code-header">pub fn <ahref="#method.find"class="fn">find</a><'h, I: <aclass="trait"href="https://doc.rust-lang.org/1.76.0/core/convert/trait.Into.html"title="trait core::convert::Into">Into</a><<aclass="struct"href="../struct.Input.html"title="struct regex_automata::Input">Input</a><'h>>>(&self, input: I) -><aclass="enum"href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html"title="enum core::option::Option">Option</a><<aclass="struct"href="../struct.Match.html"title="struct regex_automata::Match">Match</a>></h4></section></summary><divclass="docblock"><p>Executes a leftmost search and returns the first match that is found,
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.captures"class="method"><aclass="src rightside"href="../../src/regex_automata/meta/regex.rs.html#582-588">source</a><h4class="code-header">pub fn <ahref="#method.captures"class="fn">captures</a><'h, I: <aclass="trait"href="https://doc.rust-lang.org/1.76.0/core/convert/trait.Into.html"title="trait core::convert::Into">Into</a><<aclass="struct"href="../struct.Input.html"title="struct regex_automata::Input">Input</a><'h>>>(&self, input: I, caps: &mut <aclass="struct"href="../util/captures/struct.Captures.html"title="struct regex_automata::util::captures::Captures">Captures</a>)</h4></section></summary><divclass="docblock"><p>Executes a leftmost forward search and writes the spans of capturing
groups that participated in a match into the provided <ahref="../util/captures/struct.Captures.html"title="struct regex_automata::util::captures::Captures"><code>Captures</code></a>
value. If no match was found, then <ahref="../util/captures/struct.Captures.html#method.is_match"title="method regex_automata::util::captures::Captures::is_match"><code>Captures::is_match</code></a> is guaranteed
) -><aclass="struct"href="struct.FindMatches.html"title="struct regex_automata::meta::FindMatches">FindMatches</a><'r, 'h><ahref="#"class="tooltip"data-notable-ty="FindMatches<'r, 'h>">ⓘ</a></h4></section></summary><divclass="docblock"><p>Returns an iterator over all non-overlapping leftmost matches in
the given haystack. If no match exists, then the iterator yields no
) -><aclass="struct"href="struct.CapturesMatches.html"title="struct regex_automata::meta::CapturesMatches">CapturesMatches</a><'r, 'h><ahref="#"class="tooltip"data-notable-ty="CapturesMatches<'r, 'h>">ⓘ</a></h4></section></summary><divclass="docblock"><p>Returns an iterator over all non-overlapping <code>Captures</code> values. If no
match exists, then the iterator yields no elements.</p>
<p>This yields the same matches as <ahref="struct.Regex.html#method.find_iter"title="method regex_automata::meta::Regex::find_iter"><code>Regex::find_iter</code></a>, but it includes
the spans of all capturing groups that participate in each match.</p>
<p><strong>Tip:</strong> See <ahref="../util/iter/struct.Searcher.html"title="struct regex_automata::util::iter::Searcher"><code>util::iter::Searcher</code></a> for
how to correctly iterate over all matches in a haystack while avoiding
the creation of a new <code>Captures</code> value for every match. (Which you are
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.split"class="method"><aclass="src rightside"href="../../src/regex_automata/meta/regex.rs.html#815-820">source</a><h4class="code-header">pub fn <ahref="#method.split"class="fn">split</a><'r, 'h, I: <aclass="trait"href="https://doc.rust-lang.org/1.76.0/core/convert/trait.Into.html"title="trait core::convert::Into">Into</a><<aclass="struct"href="../struct.Input.html"title="struct regex_automata::Input">Input</a><'h>>>(&'r self, input: I) -><aclass="struct"href="struct.Split.html"title="struct regex_automata::meta::Split">Split</a><'r, 'h><ahref="#"class="tooltip"data-notable-ty="Split<'r, 'h>">ⓘ</a></h4></section></summary><divclass="docblock"><p>Returns an iterator of spans of the haystack given, delimited by a
match of the regex. Namely, each element of the iterator corresponds to
a part of the haystack that <em>isn’t</em> matched by the regular expression.</p>
) -><aclass="struct"href="struct.SplitN.html"title="struct regex_automata::meta::SplitN">SplitN</a><'r, 'h><ahref="#"class="tooltip"data-notable-ty="SplitN<'r, 'h>">ⓘ</a></h4></section></summary><divclass="docblock"><p>Returns an iterator of at most <code>limit</code> spans of the haystack given,
delimited by a match of the regex. (A <code>limit</code> of <code>0</code> will return no
spans.) Namely, each element of the iterator corresponds to a part
of the haystack that <em>isn’t</em> matched by the regular expression. The
remainder of the haystack that is not split will be the last element in
</div></details></div></details><detailsclass="toggle implementors-toggle"open><summary><sectionid="impl-Regex-2"class="impl"><aclass="src rightside"href="../../src/regex_automata/meta/regex.rs.html#898-1204">source</a><ahref="#impl-Regex-2"class="anchor">§</a><h3class="code-header">impl <aclass="struct"href="struct.Regex.html"title="struct regex_automata::meta::Regex">Regex</a></h3></section></summary><divclass="docblock"><p>Lower level search routines that give more control.</p>
</div><divclass="impl-items"><detailsclass="toggle method-toggle"open><summary><sectionid="method.search"class="method"><aclass="src rightside"href="../../src/regex_automata/meta/regex.rs.html#919-945">source</a><h4class="code-header">pub fn <ahref="#method.search"class="fn">search</a>(&self, input: &<aclass="struct"href="../struct.Input.html"title="struct regex_automata::Input">Input</a><'_>) -><aclass="enum"href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html"title="enum core::option::Option">Option</a><<aclass="struct"href="../struct.Match.html"title="struct regex_automata::Match">Match</a>></h4></section></summary><divclass="docblock"><p>Returns the start and end offset of the leftmost match. If no match
exists, then <code>None</code> is returned.</p>
<p>This is like <ahref="struct.Regex.html#method.find"title="method regex_automata::meta::Regex::find"><code>Regex::find</code></a> but, but it accepts a concrete <code>&Input</code>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.search_half"class="method"><aclass="src rightside"href="../../src/regex_automata/meta/regex.rs.html#975-984">source</a><h4class="code-header">pub fn <ahref="#method.search_half"class="fn">search_half</a>(&self, input: &<aclass="struct"href="../struct.Input.html"title="struct regex_automata::Input">Input</a><'_>) -><aclass="enum"href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html"title="enum core::option::Option">Option</a><<aclass="struct"href="../struct.HalfMatch.html"title="struct regex_automata::HalfMatch">HalfMatch</a>></h4></section></summary><divclass="docblock"><p>Returns the end offset of the leftmost match. If no match exists, then
<code>None</code> is returned.</p>
<p>This is distinct from <ahref="struct.Regex.html#method.search"title="method regex_automata::meta::Regex::search"><code>Regex::search</code></a> in that it only returns the end
of a match and not the start of the match. Depending on a variety of
implementation details, this <em>may</em> permit the regex engine to do less
overall work. For example, if a DFA is being used to execute a search,
then the start of a match usually requires running a separate DFA in
reverse to the find the start of a match. If one only needs the end of
a match, then the separate reverse scan to find the start of a match
can be skipped. (Note that the reverse scan is avoided even when using
<code>Regex::search</code> when possible, for example, in the case of an anchored
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.search_captures"class="method"><aclass="src rightside"href="../../src/regex_automata/meta/regex.rs.html#1063-1067">source</a><h4class="code-header">pub fn <ahref="#method.search_captures"class="fn">search_captures</a>(&self, input: &<aclass="struct"href="../struct.Input.html"title="struct regex_automata::Input">Input</a><'_>, caps: &mut <aclass="struct"href="../util/captures/struct.Captures.html"title="struct regex_automata::util::captures::Captures">Captures</a>)</h4></section></summary><divclass="docblock"><p>Executes a leftmost forward search and writes the spans of capturing
groups that participated in a match into the provided <ahref="../util/captures/struct.Captures.html"title="struct regex_automata::util::captures::Captures"><code>Captures</code></a>
value. If no match was found, then <ahref="../util/captures/struct.Captures.html#method.is_match"title="method regex_automata::util::captures::Captures::is_match"><code>Captures::is_match</code></a> is guaranteed
to return <code>false</code>.</p>
<p>This is like <ahref="struct.Regex.html#method.captures"title="method regex_automata::meta::Regex::captures"><code>Regex::captures</code></a>, but it accepts a concrete <code>&Input</code>
instead of an <code>Into<Input></code>.</p>
<h5id="example-specific-pattern-search"><ahref="#example-specific-pattern-search">Example: specific pattern search</a></h5>
<p>This example shows how to build a multi-pattern <code>Regex</code> that permits
<h5id="example-specifying-the-bounds-of-a-search"><ahref="#example-specifying-the-bounds-of-a-search">Example: specifying the bounds of a search</a></h5>
<p>This example shows how providing the bounds of a search can produce
different results than simply sub-slicing the haystack.</p>
) -><aclass="enum"href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html"title="enum core::option::Option">Option</a><<aclass="struct"href="../struct.PatternID.html"title="struct regex_automata::PatternID">PatternID</a>></h4></section></summary><divclass="docblock"><p>Executes a leftmost forward search and writes the spans of capturing
groups that participated in a match into the provided <code>slots</code>, and
returns the matching pattern ID. The contents of the slots for patterns
other than the matching pattern are unspecified. If no match was found,
then <code>None</code> is returned and the contents of <code>slots</code> is unspecified.</p>
<p>This is like <ahref="struct.Regex.html#method.search"title="method regex_automata::meta::Regex::search"><code>Regex::search</code></a>, but it accepts a raw slots slice
instead of a <code>Captures</code> value. This is useful in contexts where you
don’t want or need to allocate a <code>Captures</code>.</p>
<p>It is legal to pass <em>any</em> number of slots to this routine. If the regex
engine would otherwise write a slot offset that doesn’t fit in the
provided slice, then it is simply skipped. In general though, there are
usually three slice lengths you might want to use:</p>
<ul>
<li>An empty slice, if you only care about which pattern matched.</li>
<li>A slice with <ahref="struct.Regex.html#method.pattern_len"title="method regex_automata::meta::Regex::pattern_len"><code>pattern_len() * 2</code></a> slots, if you
only care about the overall match spans for each matching pattern.</li>
<li>A slice with
<ahref="../util/captures/struct.GroupInfo.html#method.slot_len"title="method regex_automata::util::captures::GroupInfo::slot_len"><code>slot_len()</code></a> slots, which
permits recording match offsets for every capturing group in every
)</h4></section></summary><divclass="docblock"><p>Writes the set of patterns that match anywhere in the given search
configuration to <code>patset</code>. If multiple patterns match at the same
position and this <code>Regex</code> was configured with <ahref="../enum.MatchKind.html#variant.All"title="variant regex_automata::MatchKind::All"><code>MatchKind::All</code></a>
semantics, then all matching patterns are written to the given set.</p>
<p>Unless all of the patterns in this <code>Regex</code> are anchored, then generally
speaking, this will scan the entire haystack.</p>
<p>This search routine <em>does not</em> clear the pattern set. This gives some
flexibility to the caller (e.g., running multiple searches with the
same pattern set), but does make the API bug-prone if you’re reusing
the same pattern set for multiple searches but intended them to be
independent.</p>
<p>If a pattern ID matched but the given <code>PatternSet</code> does not have
sufficient capacity to store it, then it is not inserted and silently
<p>This example shows how to find all matching patterns in a haystack,
even when some patterns match at the same position as other patterns.
It is important that we configure the <code>Regex</code> with <ahref="../enum.MatchKind.html#variant.All"title="variant regex_automata::MatchKind::All"><code>MatchKind::All</code></a>
semantics here, or else overlapping matches will not be reported.</p>
</div></details></div></details><detailsclass="toggle implementors-toggle"open><summary><sectionid="impl-Regex-3"class="impl"><aclass="src rightside"href="../../src/regex_automata/meta/regex.rs.html#1208-1494">source</a><ahref="#impl-Regex-3"class="anchor">§</a><h3class="code-header">impl <aclass="struct"href="struct.Regex.html"title="struct regex_automata::meta::Regex">Regex</a></h3></section></summary><divclass="docblock"><p>Lower level search routines that give more control, and require the caller
to provide an explicit <ahref="struct.Cache.html"title="struct regex_automata::meta::Cache"><code>Cache</code></a> parameter.</p>
</div><divclass="impl-items"><detailsclass="toggle method-toggle"open><summary><sectionid="method.search_with"class="method"><aclass="src rightside"href="../../src/regex_automata/meta/regex.rs.html#1240-1249">source</a><h4class="code-header">pub fn <ahref="#method.search_with"class="fn">search_with</a>(&self, cache: &mut <aclass="struct"href="struct.Cache.html"title="struct regex_automata::meta::Cache">Cache</a>, input: &<aclass="struct"href="../struct.Input.html"title="struct regex_automata::Input">Input</a><'_>) -><aclass="enum"href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html"title="enum core::option::Option">Option</a><<aclass="struct"href="../struct.Match.html"title="struct regex_automata::Match">Match</a>></h4></section></summary><divclass="docblock"><p>This is like <ahref="struct.Regex.html#method.search"title="method regex_automata::meta::Regex::search"><code>Regex::search</code></a>, but requires the caller to
explicitly pass a <ahref="struct.Cache.html"title="struct regex_automata::meta::Cache"><code>Cache</code></a>.</p>
<h5id="why-pass-a-cache-explicitly"><ahref="#why-pass-a-cache-explicitly">Why pass a <code>Cache</code> explicitly?</a></h5>
<p>Passing a <code>Cache</code> explicitly will bypass the use of an internal memory
pool used by <code>Regex</code> to get a <code>Cache</code> for a search. The use of this
pool can be slower in some cases when a <code>Regex</code> is used from multiple
threads simultaneously. Typically, performance only becomes an issue
when there is heavy contention, which in turn usually only occurs
when each thread’s primary unit of work is a regex search on a small
) -><aclass="enum"href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html"title="enum core::option::Option">Option</a><<aclass="struct"href="../struct.HalfMatch.html"title="struct regex_automata::HalfMatch">HalfMatch</a>></h4></section></summary><divclass="docblock"><p>This is like <ahref="struct.Regex.html#method.search_half"title="method regex_automata::meta::Regex::search_half"><code>Regex::search_half</code></a>, but requires the caller to
explicitly pass a <ahref="struct.Cache.html"title="struct regex_automata::meta::Cache"><code>Cache</code></a>.</p>
<h5id="why-pass-a-cache-explicitly-1"><ahref="#why-pass-a-cache-explicitly-1">Why pass a <code>Cache</code> explicitly?</a></h5>
<p>Passing a <code>Cache</code> explicitly will bypass the use of an internal memory
pool used by <code>Regex</code> to get a <code>Cache</code> for a search. The use of this
pool can be slower in some cases when a <code>Regex</code> is used from multiple
threads simultaneously. Typically, performance only becomes an issue
when there is heavy contention, which in turn usually only occurs
when each thread’s primary unit of work is a regex search on a small
)</h4></section></summary><divclass="docblock"><p>This is like <ahref="struct.Regex.html#method.search_captures"title="method regex_automata::meta::Regex::search_captures"><code>Regex::search_captures</code></a>, but requires the caller to
explicitly pass a <ahref="struct.Cache.html"title="struct regex_automata::meta::Cache"><code>Cache</code></a>.</p>
<h5id="why-pass-a-cache-explicitly-2"><ahref="#why-pass-a-cache-explicitly-2">Why pass a <code>Cache</code> explicitly?</a></h5>
<p>Passing a <code>Cache</code> explicitly will bypass the use of an internal memory
pool used by <code>Regex</code> to get a <code>Cache</code> for a search. The use of this
pool can be slower in some cases when a <code>Regex</code> is used from multiple
threads simultaneously. Typically, performance only becomes an issue
when there is heavy contention, which in turn usually only occurs
when each thread’s primary unit of work is a regex search on a small
haystack.</p>
<h5id="example-specific-pattern-search-1"><ahref="#example-specific-pattern-search-1">Example: specific pattern search</a></h5>
<p>This example shows how to build a multi-pattern <code>Regex</code> that permits
<h5id="example-specifying-the-bounds-of-a-search-1"><ahref="#example-specifying-the-bounds-of-a-search-1">Example: specifying the bounds of a search</a></h5>
<p>This example shows how providing the bounds of a search can produce
different results than simply sub-slicing the haystack.</p>
) -><aclass="enum"href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html"title="enum core::option::Option">Option</a><<aclass="struct"href="../struct.PatternID.html"title="struct regex_automata::PatternID">PatternID</a>></h4></section></summary><divclass="docblock"><p>This is like <ahref="struct.Regex.html#method.search_slots"title="method regex_automata::meta::Regex::search_slots"><code>Regex::search_slots</code></a>, but requires the caller to
explicitly pass a <ahref="struct.Cache.html"title="struct regex_automata::meta::Cache"><code>Cache</code></a>.</p>
<h5id="why-pass-a-cache-explicitly-3"><ahref="#why-pass-a-cache-explicitly-3">Why pass a <code>Cache</code> explicitly?</a></h5>
<p>Passing a <code>Cache</code> explicitly will bypass the use of an internal memory
pool used by <code>Regex</code> to get a <code>Cache</code> for a search. The use of this
pool can be slower in some cases when a <code>Regex</code> is used from multiple
threads simultaneously. Typically, performance only becomes an issue
when there is heavy contention, which in turn usually only occurs
when each thread’s primary unit of work is a regex search on a small
)</h4></section></summary><divclass="docblock"><p>This is like <ahref="struct.Regex.html#method.which_overlapping_matches"title="method regex_automata::meta::Regex::which_overlapping_matches"><code>Regex::which_overlapping_matches</code></a>, but requires the
caller to explicitly pass a <ahref="struct.Cache.html"title="struct regex_automata::meta::Cache"><code>Cache</code></a>.</p>
<p>Passing a <code>Cache</code> explicitly will bypass the use of an internal memory
pool used by <code>Regex</code> to get a <code>Cache</code> for a search. The use of this
pool can be slower in some cases when a <code>Regex</code> is used from multiple
threads simultaneously. Typically, performance only becomes an issue
when there is heavy contention, which in turn usually only occurs
when each thread’s primary unit of work is a regex search on a small
haystack.</p>
<h5id="why-pass-a-cache-explicitly-4"><ahref="#why-pass-a-cache-explicitly-4">Why pass a <code>Cache</code> explicitly?</a></h5><h5id="example-16"><ahref="#example-16">Example</a></h5>
</div></details></div></details><detailsclass="toggle implementors-toggle"open><summary><sectionid="impl-Regex-4"class="impl"><aclass="src rightside"href="../../src/regex_automata/meta/regex.rs.html#1498-1897">source</a><ahref="#impl-Regex-4"class="anchor">§</a><h3class="code-header">impl <aclass="struct"href="struct.Regex.html"title="struct regex_automata::meta::Regex">Regex</a></h3></section></summary><divclass="docblock"><p>Various non-search routines for querying properties of a <code>Regex</code> and
convenience routines for creating <ahref="../util/captures/struct.Captures.html"title="struct regex_automata::util::captures::Captures"><code>Captures</code></a> and <ahref="struct.Cache.html"title="struct regex_automata::meta::Cache"><code>Cache</code></a> values.</p>
</div><divclass="impl-items"><detailsclass="toggle method-toggle"open><summary><sectionid="method.create_captures"class="method"><aclass="src rightside"href="../../src/regex_automata/meta/regex.rs.html#1558-1560">source</a><h4class="code-header">pub fn <ahref="#method.create_captures"class="fn">create_captures</a>(&self) -><aclass="struct"href="../util/captures/struct.Captures.html"title="struct regex_automata::util::captures::Captures">Captures</a></h4></section></summary><divclass="docblock"><p>Creates a new object for recording capture group offsets. This is used
in search APIs like <ahref="struct.Regex.html#method.captures"title="method regex_automata::meta::Regex::captures"><code>Regex::captures</code></a> and <ahref="struct.Regex.html#method.search_captures"title="method regex_automata::meta::Regex::search_captures"><code>Regex::search_captures</code></a>.</p>
<p>This is a convenience routine for
<code>Captures::all(re.group_info().clone())</code>. Callers may build other types
of <code>Captures</code> values that record less information (and thus require
less work from the regex engine) using <ahref="../util/captures/struct.Captures.html#method.matches"title="associated function regex_automata::util::captures::Captures::matches"><code>Captures::matches</code></a> and
<ahref="../util/captures/struct.Captures.html#method.empty"title="associated function regex_automata::util::captures::Captures::empty"><code>Captures::empty</code></a>.</p>
<p>This shows some alternatives to <ahref="struct.Regex.html#method.create_captures"title="method regex_automata::meta::Regex::create_captures"><code>Regex::create_captures</code></a>:</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.create_cache"class="method"><aclass="src rightside"href="../../src/regex_automata/meta/regex.rs.html#1586-1588">source</a><h4class="code-header">pub fn <ahref="#method.create_cache"class="fn">create_cache</a>(&self) -><aclass="struct"href="struct.Cache.html"title="struct regex_automata::meta::Cache">Cache</a></h4></section></summary><divclass="docblock"><p>Creates a new cache for use with lower level search APIs like
<p>The cache returned should only be used for searches for this <code>Regex</code>.
If you want to reuse the cache for another <code>Regex</code>, then you must call
<ahref="struct.Cache.html#method.reset"title="method regex_automata::meta::Cache::reset"><code>Cache::reset</code></a> with that <code>Regex</code>.</p>
<p>This is a convenience routine for <ahref="struct.Cache.html#method.new"title="associated function regex_automata::meta::Cache::new"><code>Cache::new</code></a>.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.pattern_len"class="method"><aclass="src rightside"href="../../src/regex_automata/meta/regex.rs.html#1616-1618">source</a><h4class="code-header">pub fn <ahref="#method.pattern_len"class="fn">pattern_len</a>(&self) -><aclass="primitive"href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a></h4></section></summary><divclass="docblock"><p>Returns the total number of patterns in this regex.</p>
<p>The standard <ahref="struct.Regex.html#method.new"title="associated function regex_automata::meta::Regex::new"><code>Regex::new</code></a> constructor always results in a <code>Regex</code>
with a single pattern, but <ahref="struct.Regex.html#method.new_many"title="associated function regex_automata::meta::Regex::new_many"><code>Regex::new_many</code></a> permits building a
multi-pattern regex.</p>
<p>A <code>Regex</code> guarantees that the maximum possible <code>PatternID</code> returned in
any match is <code>Regex::pattern_len() - 1</code>. In the case where the number
of patterns is <code>0</code>, a match is impossible.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.captures_len"class="method"><aclass="src rightside"href="../../src/regex_automata/meta/regex.rs.html#1671-1677">source</a><h4class="code-header">pub fn <ahref="#method.captures_len"class="fn">captures_len</a>(&self) -><aclass="primitive"href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a></h4></section></summary><divclass="docblock"><p>Returns the total number of capturing groups.</p>
<p>This includes the implicit capturing group corresponding to the
entire match. Therefore, the minimum value returned is <code>1</code>.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.static_captures_len"class="method"><aclass="src rightside"href="../../src/regex_automata/meta/regex.rs.html#1740-1746">source</a><h4class="code-header">pub fn <ahref="#method.static_captures_len"class="fn">static_captures_len</a>(&self) -><aclass="enum"href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html"title="enum core::option::Option">Option</a><<aclass="primitive"href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>></h4></section></summary><divclass="docblock"><p>Returns the total number of capturing groups that appear in every
possible match.</p>
<p>If the number of capture groups can vary depending on the match, then
this returns <code>None</code>. That is, a value is only returned when the number
of matching groups is invariant or “static.”</p>
<p>Note that like <ahref="struct.Regex.html#method.captures_len"title="method regex_automata::meta::Regex::captures_len"><code>Regex::captures_len</code></a>, this <strong>does</strong> include the
implicit capturing group corresponding to the entire match. Therefore,
when a non-None value is returned, it is guaranteed to be at least <code>1</code>.
Stated differently, a return value of <code>Some(0)</code> is impossible.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.group_info"class="method"><aclass="src rightside"href="../../src/regex_automata/meta/regex.rs.html#1812-1814">source</a><h4class="code-header">pub fn <ahref="#method.group_info"class="fn">group_info</a>(&self) ->&<aclass="struct"href="../util/captures/struct.GroupInfo.html"title="struct regex_automata::util::captures::GroupInfo">GroupInfo</a></h4></section></summary><divclass="docblock"><p>Return information about the capture groups in this <code>Regex</code>.</p>
<p>A <code>GroupInfo</code> is an immutable object that can be cheaply cloned. It
is responsible for maintaining a mapping between the capture groups
in the concrete syntax of zero or more regex patterns and their
internal representation used by some of the regex matchers. It is also
responsible for maintaining a mapping between the name of each group
(if one exists) and its corresponding group index.</p>
<p>A <code>GroupInfo</code> is ultimately what is used to build a <ahref="../util/captures/struct.Captures.html"title="struct regex_automata::util::captures::Captures"><code>Captures</code></a> value,
which is some mutable space where group offsets are stored as a result
<p>This shows some alternatives to <ahref="struct.Regex.html#method.create_captures"title="method regex_automata::meta::Regex::create_captures"><code>Regex::create_captures</code></a>:</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.get_config"class="method"><aclass="src rightside"href="../../src/regex_automata/meta/regex.rs.html#1821-1823">source</a><h4class="code-header">pub fn <ahref="#method.get_config"class="fn">get_config</a>(&self) ->&<aclass="struct"href="struct.Config.html"title="struct regex_automata::meta::Config">Config</a></h4></section></summary><divclass="docblock"><p>Returns the configuration object used to build this <code>Regex</code>.</p>
<p>If no configuration object was explicitly passed, then the
configuration returned represents the default.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.is_accelerated"class="method"><aclass="src rightside"href="../../src/regex_automata/meta/regex.rs.html#1872-1874">source</a><h4class="code-header">pub fn <ahref="#method.is_accelerated"class="fn">is_accelerated</a>(&self) -><aclass="primitive"href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a></h4></section></summary><divclass="docblock"><p>Returns true if this regex has a high chance of being “accelerated.”</p>
<p>The precise meaning of “accelerated” is specifically left unspecified,
but the general meaning is that the search is a high likelihood of
running faster than than a character-at-a-time loop inside a standard
regex engine.</p>
<p>When a regex is accelerated, it is only a <em>probabilistic</em> claim. That
is, just because the regex is believed to be accelerated, that doesn’t
mean it will definitely execute searches very fast. Similarly, if a
regex is <em>not</em> accelerated, that is also a probabilistic claim. That
is, a regex for which <code>is_accelerated</code> returns <code>false</code> could still run
searches more quickly than a regex for which <code>is_accelerated</code> returns
<code>true</code>.</p>
<p>Whether a regex is marked as accelerated or not is dependent on
implementations details that may change in a semver compatible release.
That is, a regex that is accelerated in a <code>x.y.1</code> release might not be
accelerated in a <code>x.y.2</code> release.</p>
<p>Basically, the value of acceleration boils down to a hedge: a hodge
podge of internal heuristics combine to make a probabilistic guess
that this regex search may run “fast.” The value in knowing this from
a caller’s perspective is that it may act as a signal that no further
work should be done to accelerate a search. For example, a grep-like
tool might try to do some extra work extracting literals from a regex
to create its own heuristic acceleration strategies. But it might
choose to defer to this crate’s acceleration strategy if one exists.
This routine permits querying whether such a strategy is active for a
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.memory_usage"class="method"><aclass="src rightside"href="../../src/regex_automata/meta/regex.rs.html#1894-1896">source</a><h4class="code-header">pub fn <ahref="#method.memory_usage"class="fn">memory_usage</a>(&self) -><aclass="primitive"href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a></h4></section></summary><divclass="docblock"><p>Return the total approximate heap memory, in bytes, used by this <code>Regex</code>.</p>
<p>Note that currently, there is no high level configuration for setting
a limit on the specific value returned by this routine. Instead, the
following routines can be used to control heap memory at a bit of a
lower level:</p>
<ul>
<li><ahref="struct.Config.html#method.nfa_size_limit"title="method regex_automata::meta::Config::nfa_size_limit"><code>Config::nfa_size_limit</code></a> controls how big <em>any</em> of the NFAs are
allowed to be.</li>
<li><ahref="struct.Config.html#method.onepass_size_limit"title="method regex_automata::meta::Config::onepass_size_limit"><code>Config::onepass_size_limit</code></a> controls how big the one-pass DFA is
allowed to be.</li>
<li><ahref="struct.Config.html#method.hybrid_cache_capacity"title="method regex_automata::meta::Config::hybrid_cache_capacity"><code>Config::hybrid_cache_capacity</code></a> controls how much memory the lazy
DFA is permitted to allocate to store its transition table.</li>
<li><ahref="struct.Config.html#method.dfa_size_limit"title="method regex_automata::meta::Config::dfa_size_limit"><code>Config::dfa_size_limit</code></a> controls how big a fully compiled DFA is
allowed to be.</li>
<li><ahref="struct.Config.html#method.dfa_state_limit"title="method regex_automata::meta::Config::dfa_state_limit"><code>Config::dfa_state_limit</code></a> controls the conditions under which the
meta regex engine will even attempt to build a fully compiled DFA.</li>
</ul>
</div></details></div></details></div><h2id="trait-implementations"class="section-header">Trait Implementations<ahref="#trait-implementations"class="anchor">§</a></h2><divid="trait-implementations-list"><detailsclass="toggle implementors-toggle"open><summary><sectionid="impl-Clone-for-Regex"class="impl"><aclass="src rightside"href="../../src/regex_automata/meta/regex.rs.html#1899-1909">source</a><ahref="#impl-Clone-for-Regex"class="anchor">§</a><h3class="code-header">impl <aclass="trait"href="https://doc.rust-lang.org/1.76.0/core/clone/trait.Clone.html"title="trait core::clone::Clone">Clone</a> for <aclass="struct"href="struct.Regex.html"title="struct regex_automata::meta::Regex">Regex</a></h3></section></summary><divclass="impl-items"><detailsclass="toggle method-toggle"open><summary><sectionid="method.clone"class="method trait-impl"><aclass="src rightside"href="../../src/regex_automata/meta/regex.rs.html#1900-1908">source</a><ahref="#method.clone"class="anchor">§</a><h4class="code-header">fn <ahref="https://doc.rust-lang.org/1.76.0/core/clone/trait.Clone.html#tymethod.clone"class="fn">clone</a>(&self) -><aclass="struct"href="struct.Regex.html"title="struct regex_automata::meta::Regex">Regex</a></h4></section></summary><divclass='docblock'>Returns a copy of the value. <ahref="https://doc.rust-lang.org/1.76.0/core/clone/trait.Clone.html#tymethod.clone">Read more</a></div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.clone_from"class="method trait-impl"><spanclass="rightside"><spanclass="since"title="Stable since Rust version 1.0.0">1.0.0</span> · <aclass="src"href="https://doc.rust-lang.org/1.76.0/src/core/clone.rs.html#169">source</a></span><ahref="#method.clone_from"class="anchor">§</a><h4class="code-header">fn <ahref="https://doc.rust-lang.org/1.76.0/core/clone/trait.Clone.html#method.clone_from"class="fn">clone_from</a>(&mut self, source: <aclass="primitive"href="https://doc.rust-lang.org/1.76.0/std/primitive.reference.html">&Self</a>)</h4></section></summary><divclass='docblock'>Performs copy-assignment from <code>source</code>. <ahref="https://doc.rust-lang.org/1.76.0/core/clone/trait.Clone.html#method.clone_from">Read more</a></div></details></div></details><detailsclass="toggle implementors-toggle"open><summary><sectionid="impl-Debug-for-Regex"class="impl"><aclass="src rightside"href="../../src/regex_automata/meta/regex.rs.html#234">source</a><ahref="#impl-Debug-for-Regex"class="anchor">§</a><h3class="code-header">impl <aclass="trait"href="https://doc.rust-lang.org/1.76.0/core/fmt/trait.Debug.html"title="trait core::fmt::Debug">Debug</a> for <aclass="struct"href="struct.Regex.html"title="struct regex_automata::meta::Regex">Regex</a></h3></section></summary><divclass="impl-items"><detailsclass="toggle method-toggle"open><summary><sectionid="method.fmt"class="method trait-impl"><aclass="src rightside"href="../../src/regex_automata/meta/regex.rs.html#234">source</a><ahref="#method.fmt"class="anchor">§</a><h4class="code-header">fn <ahref="https://doc.rust-lang.org/1.76.0/core/fmt/trait.Debug.html#tymethod.fmt"class="fn">fmt</a>(&self, f: &mut <aclass="struct"href="https://doc.rust-lang.org/1.76.0/core/fmt/struct.Formatter.html"title="struct core::fmt::Formatter">Formatter</a><'_>) -><aclass="type"href="https://doc.rust-lang.org/1.76.0/core/fmt/type.Result.html"title="type core::fmt::Result">Result</a></h4></section></summary><divclass='docblock'>Formats the value using the given formatter. <ahref="https://doc.rust-lang.org/1.76.0/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></div></details></div></details></div><h2id="synthetic-implementations"class="section-header">Auto Trait Implementations<ahref="#synthetic-implementations"class="anchor">§</a></h2><divid="synthetic-implementations-list"><sectionid="impl-RefUnwindSafe-for-Regex"class="impl"><ahref="#impl-RefUnwindSafe-for-Regex"class="anchor">§</a><h3class="code-header">impl <aclass
T: 'static + ?<aclass="trait"href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html"title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><divclass="impl-items"><detailsclass="toggle method-toggle"open><summary><sectionid="method.type_id"class="method trait-impl"><aclass="src rightside"href="https://doc.rust-lang.org/1.76.0/src/core/any.rs.html#141">source</a><ahref="#method.type_id"class="anchor">§</a><h4class="code-header">fn <ahref="https://doc.rust-lang.org/1.76.0/core/any/trait.Any.html#tymethod.type_id"class="fn">type_id</a>(&self) -><aclass="struct"href="https://doc.rust-lang.org/1.76.0/core/any/struct.TypeId.html"title="struct core::any::TypeId">TypeId</a></h4></section></summary><divclass='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <ahref="https://doc.rust-lang.org/1.76.0/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><detailsclass="toggle implementors-toggle"><summary><sectionid="impl-Borrow%3CT%3E-for-T"class="impl"><aclass="src rightside"href="https://doc.rust-lang.org/1.76.0/src/core/borrow.rs.html#208">source</a><ahref="#impl-Borrow%3CT%3E-for-T"class="anchor">§</a><h3class="code-header">impl<T><aclass="trait"href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.Borrow.html"title="trait core::borrow::Borrow">Borrow</a><T> for T<divclass="where">where
T: ?<aclass="trait"href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html"title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><divclass="impl-items"><detailsclass="toggle method-toggle"open><summary><sectionid="method.borrow"class="method trait-impl"><aclass="src rightside"href="https://doc.rust-lang.org/1.76.0/src/core/borrow.rs.html#210">source</a><ahref="#method.borrow"class="anchor">§</a><h4class="code-header">fn <ahref="https://doc.rust-lang.org/1.76.0/core/borrow/trait.Borrow.html#tymethod.borrow"class="fn">borrow</a>(&self) -><aclass="primitive"href="https://doc.rust-lang.org/1.76.0/std/primitive.reference.html">&T</a></h4></section></summary><divclass='docblock'>Immutably borrows from an owned value. <ahref="https://doc.rust-lang.org/1.76.0/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><detailsclass="toggle implementors-toggle"><summary><sectionid="impl-BorrowMut%3CT%3E-for-T"class="impl"><aclass="src rightside"href="https://doc.rust-lang.org/1.76.0/src/core/borrow.rs.html#216">source</a><ahref="#impl-BorrowMut%3CT%3E-for-T"class="anchor">§</a><h3class="code-header">impl<T><aclass="trait"href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.BorrowMut.html"title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T<divclass="where">where
T: ?<aclass="trait"href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html"title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><divclass="impl-items"><detailsclass="toggle method-toggle"open><summary><sectionid="method.borrow_mut"class="method trait-impl"><aclass="src rightside"href="https://doc.rust-lang.org/1.76.0/src/core/borrow.rs.html#217">source</a><ahref="#method.borrow_mut"class="anchor">§</a><h4class="code-header">fn <ahref="https://doc.rust-lang.org/1.76.0/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut"class="fn">borrow_mut</a>(&mut self) -><aclass="primitive"href="https://doc.rust-lang.org/1.76.0/std/primitive.reference.html">&mut T</a></h4></section></summary><divclass='docblock'>Mutably borrows from an owned value. <ahref="https://doc.rust-lang.org/1.76.0/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><detailsclass="toggle implementors-toggle"><summary><sectionid="impl-From%3CT%3E-for-T"class="impl"><aclass="src rightside"href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#763">source</a><ahref="#impl-From%3CT%3E-for-T"class="anchor">§</a><h3class="code-header">impl<T><aclass="trait"href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html"title="trait core::convert::From">From</a><T> for T</h3></section></summary><divclass="impl-items"><detailsclass="toggle method-toggle"open><summary><sectionid="method.from"class="method trait-impl"><aclass="src rightside"href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#766">source</a><ahref="#method.from"class="anchor">§</a><h4class="code-header">fn <ahref="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html#tymethod.from"class="fn">from</a>(t: T) -> T</h4></section></summary><divclass="docblock"><p>Returns the argument unchanged.</p>
</div></details></div></details><detailsclass="toggle implementors-toggle"><summary><sectionid="impl-Into%3CU%3E-for-T"class="impl"><aclass="src rightside"href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#747-749">source</a><ahref="#impl-Into%3CU%3E-for-T"class="anchor">§</a><h3class="code-header">impl<T, U><aclass="trait"href="https://doc.rust-lang.org/1.76.0/core/convert/trait.Into.html"title="trait core::convert::Into">Into</a><U> for T<divclass="where">where
<p>That is, this conversion is whatever the implementation of
<code><ahref="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html"title="trait core::convert::From">From</a><T> for U</code> chooses to do.</p>
</div></details></div></details><detailsclass="toggle implementors-toggle"><summary><sectionid="impl-ToOwned-for-T"class="impl"><aclass="src rightside"href="https://doc.rust-lang.org/1.76.0/src/alloc/borrow.rs.html#83-85">source</a><ahref="#impl-ToOwned-for-T"class="anchor">§</a><h3class="code-header">impl<T><aclass="trait"href="https://doc.rust-lang.org/1.76.0/alloc/borrow/trait.ToOwned.html"title="trait alloc::borrow::ToOwned">ToOwned</a> for T<divclass="where">where
T: <aclass="trait"href="https://doc.rust-lang.org/1.76.0/core/clone/trait.Clone.html"title="trait core::clone::Clone">Clone</a>,</div></h3></section></summary><divclass="impl-items"><detailsclass="toggle"open><summary><sectionid="associatedtype.Owned"class="associatedtype trait-impl"><ahref="#associatedtype.Owned"class="anchor">§</a><h4class="code-header">type <ahref="https://doc.rust-lang.org/1.76.0/alloc/borrow/trait.ToOwned.html#associatedtype.Owned"class="associatedtype">Owned</a> = T</h4></section></summary><divclass='docblock'>The resulting type after obtaining ownership.</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.to_owned"class="method trait-impl"><aclass="src rightside"href="https://doc.rust-lang.org/1.76.0/src/alloc/borrow.rs.html#88">source</a><ahref="#method.to_owned"class="anchor">§</a><h4class="code-header">fn <ahref="https://doc.rust-lang.org/1.76.0/alloc/borrow/trait.ToOwned.html#tymethod.to_owned"class="fn">to_owned</a>(&self) -> T</h4></section></summary><divclass='docblock'>Creates owned data from borrowed data, usually by cloning. <ahref="https://doc.rust-lang.org/1.76.0/alloc/borrow/trait.ToOwned.html#tymethod.to_owned">Read more</a></div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.clone_into"class="method trait-impl"><aclass="src rightside"href="https://doc.rust-lang.org/1.76.0/src/alloc/borrow.rs.html#92">source</a><ahref="#method.clone_into"class="anchor">§</a><h4class="code-header">fn <ahref="https://doc.rust-lang.org/1.76.0/alloc/borrow/trait.ToOwned.html#method.clone_into"class="fn">clone_into</a>(&self, target: <aclass="primitive"href="https://doc.rust-lang.org/1.76.0/std/primitive.reference.html">&mut T</a>)</h4></section></summary><divclass='docblock'>Uses borrowed data to replace owned data, usually by cloning. <ahref="https://doc.rust-lang.org/1.76.0/alloc/borrow/trait.ToOwned.html#method.clone_into">Read more</a></div></details></div></details><detailsclass="toggle implementors-toggle"><summary><sectionid="impl-TryFrom%3CU%3E-for-T"class="impl"><aclass="src rightside"href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#803-805">source</a><ahref="#impl-TryFrom%3CU%3E-for-T"class="anchor">§</a><h3class="code-header">impl<T, U><aclass="trait"href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html"title="trait core::convert::TryFrom">TryFrom</a><U> for T<divclass="where">where
U: <aclass="trait"href="https://doc.rust-lang.org/1.76.0/core/convert/trait.Into.html"title="trait core::convert::Into">Into</a><T>,</div></h3></section></summary><divclass="impl-items"><detailsclass="toggle"open><summary><sectionid="associatedtype.Error"class="associatedtype trait-impl"><ahref="#associatedtype.Error"class="anchor">§</a><h4class="code-header">type <ahref="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html#associatedtype.Error"class="associatedtype">Error</a> = <aclass="enum"href="https://doc.rust-lang.org/1.76.0/core/convert/enum.Infallible.html"title="enum core::convert::Infallible">Infallible</a></h4></section></summary><divclass='docblock'>The type returned in the event of a conversion error.</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.try_from"class="method trait-impl"><aclass="src rightside"href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#810">source</a><ahref="#method.try_from"class="anchor">§</a><h4class="code-header">fn <ahref="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html#tymethod.try_from"class="fn">try_from</a>(value: U) -><aclass="enum"href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html"title="enum core::result::Result">Result</a><T, <T as <aclass="trait"href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html"title="trait core::convert::TryFrom">TryFrom</a><U>>::<aclass="associatedtype"href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html#associatedtype.Error"title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><divclass='docblock'>Performs the conversion.</div></details></div></details><detailsclass="toggle implementors-toggle"><summary><sectionid="impl-TryInto%3CU%3E-for-T"class="impl"><aclass="src rightside"href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#788-790">source</a><ahref="#impl-TryInto%3CU%3E-for-T"class="anchor">§</a><h3class="code-header">impl<T, U><aclass="trait"href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryInto.html"title="trait core::convert::TryInto">TryInto</a><U> for T<divclass="where">where
U: <aclass="trait"href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html"title="trait core::convert::TryFrom">TryFrom</a><T>,</div></h3></section></summary><divclass="impl-items"><detailsclass="toggle"open><summary><sectionid="associatedtype.Error-1"class="associatedtype trait-impl"><ahref="#associatedtype.Error-1"class="anchor">§</a><h4class="code-header">type <ahref="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryInto.html#associatedtype.Error"class="associatedtype">Error</a> = <U as <aclass="trait"href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html"title="trait core::convert::TryFrom">TryFrom</a><T>>::<aclass="associatedtype"href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html#associatedtype.Error"title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><divclass='docblock'>The type returned in the event of a conversion error.</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.try_into"class="method trait-impl"><aclass="src rightside"href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#795">source</a><ahref="#method.try_into"class="anchor">§</a><h4class="code-header">fn <ahref="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryInto.html#tymethod.try_into"class="fn">try_into</a>(self) -><aclass="enum"href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html"title="enum core::result::Result">Result</a><U, <U as <aclass="trait"href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html"title="trait core::convert::TryFrom">TryFrom</a><T>>::<aclass="associatedtype"href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html#associatedtype.Error"title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><divclass='docblock'>Performs the conversion.</div></details></div></details></div><scripttype="text/json"id="notable-traits-data">{"CapturesMatches<'r,'h>":"<h3>Notabletraitsfor<code><aclass=\"struct\"href=\"struct.CapturesMatches.html\"title=\"structregex_automata::meta::CapturesMatches\">CapturesMatches</a><'r,'h></code></h3><pre><code><divclass=\"where\">impl<'r,'h><aclass=\"trait\"href=\"https://doc.rust-lang.org/1.76.0/core/iter/traits/iterator/trait.Iterator.html\"title=\"traitcore::iter::traits::iterator::Iterator\">Iterator</a>for<aclass=\"struct\"href=\"struct.CapturesMatches.html\"title=\"structregex_automata::meta::CapturesMatches\">CapturesMatches</a><'r,'h></div><divclass=\"where\">type<ahref=\"https://doc.rust-lang.org/1.76.0/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item\"class=\"associatedtype\">Item</a>=<aclass=\"struct\"href=\"../util/captures/struct.Captures.html\"title=\"structregex_automata::util::captures::Captures\">Captures</a>;</div>","FindMatches<'r,'h>":"<h3>Notabletraitsfor<code><aclass=\"struct\"href=\"struct.FindMatches.html\"title=\"structregex_automata::meta::FindMatches\">FindMatches</a><'r,'h></code></h3><pre><code><divclass=\"where\">impl<'r,'h><aclass=\"trait\"href=\"https://doc.rust-lang.org/1.76.0/core/iter/traits/iterator/trait.Iterator.html\"title=\"traitcore::iter::traits::iterator::Iterator\">Iterator</a>for<aclass=\"struct\"href=\"struct.FindMatches.html\"title=\"structregex_automata::meta::FindMatches\">FindMatches</a><'r,'h></div><divclass=\"where\">type<ahref=\"https://doc.rust-lang.org/1.76.0/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item\"class=\"associatedtype\">Item</a>=<aclass=\"struct\"href=\"../struct.Match.html\"title=\"structregex_automata::Match\">Match</a>;</div>","Split<'r,'h>":"<h3>Notabletraitsfor<code><aclass=\"struct\"href=\"struct.Split.html\"title=\"structregex_automata::meta::Split\">Split</a><'r,'h></code></h3><pre><code><divclass=\"where\">impl<'r,'h><aclass=\"trait\"href=\"https://doc.rust-lang.org/1.76.0/core/iter/tr