<main><divclass="width-limiter"><navclass="sub"><formclass="search-form"><span></span><divid="sidebar-button"tabindex="-1"><ahref="../../regex/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</a>::<wbr><ahref="index.html">bytes</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/regex/bytes.rs.html#99-102">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 compiled regular expression for searching Unicode haystacks.</p>
<p>A <code>Regex</code> can be used to search haystacks, split haystacks into substrings
or replace substrings in a haystack with a different substring. All
searching is done with an implicit <code>(?s:.)*?</code> at the beginning and end of
an pattern. To force an expression to match the whole string (or a prefix
or a suffix), you must use an anchor like <code>^</code> or <code>$</code> (or <code>\A</code> and <code>\z</code>).</p>
<p>Like the <code>Regex</code> type in the parent module, matches with this regex return
byte offsets into the haystack. <strong>Unlike</strong> the parent <code>Regex</code> type, these
byte offsets may not correspond to UTF-8 sequence boundaries since the
regexes in this module can match arbitrary bytes.</p>
<p>The only methods that allocate new byte strings are the string replacement
methods. All other methods (searching and splitting) return borrowed
<p>A common way to use regexes is with capture groups. That is, instead of
just looking for matches of an entire regex, parentheses are used to create
groups that represent part of the match.</p>
<p>For example, consider a haystack with multiple lines, and each line has
three whitespace delimited fields where the second field is expected to be
a number and the third field a boolean. To make this convenient, we use
the <ahref="struct.Captures.html#method.extract"title="method regex::bytes::Captures::extract"><code>Captures::extract</code></a> API to put the strings that match each group
</div><divclass="impl-items"><detailsclass="toggle method-toggle"open><summary><sectionid="method.new"class="method"><aclass="src rightside"href="../../src/regex/regex/bytes.rs.html#178-180">source</a><h4class="code-header">pub fn <ahref="#method.new"class="fn">new</a>(re: &<aclass="primitive"href="https://doc.rust-lang.org/1.77.0/std/primitive.str.html">str</a>) -><aclass="enum"href="https://doc.rust-lang.org/1.77.0/core/result/enum.Result.html"title="enum core::result::Result">Result</a><<aclass="struct"href="struct.Regex.html"title="struct regex::bytes::Regex">Regex</a>, <aclass="enum"href="../enum.Error.html"title="enum regex::Error">Error</a>></h4></section></summary><divclass="docblock"><p>Compiles a regular expression. Once compiled, it can be used repeatedly
<p>If an invalid pattern is given, then an error is returned.
An error is also returned if the pattern is valid, but would
produce a regex that is bigger than the configured size limit via
<ahref="struct.RegexBuilder.html#method.size_limit"title="method regex::bytes::RegexBuilder::size_limit"><code>RegexBuilder::size_limit</code></a>. (A reasonable size limit is enabled by
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.is_match"class="method"><aclass="src rightside"href="../../src/regex/regex/bytes.rs.html#202-204">source</a><h4class="code-header">pub fn <ahref="#method.is_match"class="fn">is_match</a>(&self, haystack: &[<aclass="primitive"href="https://doc.rust-lang.org/1.77.0/std/primitive.u8.html">u8</a>]) -><aclass="primitive"href="https://doc.rust-lang.org/1.77.0/std/primitive.bool.html">bool</a></h4></section></summary><divclass="docblock"><p>Returns true if and only if there is a match for the regex anywhere
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.find"class="method"><aclass="src rightside"href="../../src/regex/regex/bytes.rs.html#230-232">source</a><h4class="code-header">pub fn <ahref="#method.find"class="fn">find</a><'h>(&self, haystack: &'h [<aclass="primitive"href="https://doc.rust-lang.org/1.77.0/std/primitive.u8.html">u8</a>]) -><aclass="enum"href="https://doc.rust-lang.org/1.77.0/core/option/enum.Option.html"title="enum core::option::Option">Option</a><<aclass="struct"href="struct.Match.html"title="struct regex::bytes::Match">Match</a><'h>></h4></section></summary><divclass="docblock"><p>This routine searches for the first match of this regex in the
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.captures"class="method"><aclass="src rightside"href="../../src/regex/regex/bytes.rs.html#353-355">source</a><h4class="code-header">pub fn <ahref="#method.captures"class="fn">captures</a><'h>(&self, haystack: &'h [<aclass="primitive"href="https://doc.rust-lang.org/1.77.0/std/primitive.u8.html">u8</a>]) -><aclass="enum"href="https://doc.rust-lang.org/1.77.0/core/option/enum.Option.html"title="enum core::option::Option">Option</a><<aclass="struct"href="struct.Captures.html"title="struct regex::bytes::Captures">Captures</a><'h>></h4></section></summary><divclass="docblock"><p>This routine searches for the first match of this regex in the haystack
given, and if found, returns not only the overall match but also the
matches of each capture group in the regex. If no match is found, then
<code>None</code> is returned.</p>
<p>Capture group <code>0</code> always corresponds to an implicit unnamed group that
includes the entire match. If a match is found, this group is always
present. Subsequent groups may be named and are numbered, starting
at 1, by the order in which the opening parenthesis appears in the
pattern. For example, in the pattern <code>(?<a>.(?<b>.))(?<c>.)</code>, <code>a</code>,
<code>b</code> and <code>c</code> correspond to capture group indices <code>1</code>, <code>2</code> and <code>3</code>,
respectively.</p>
<p>You should only use <code>captures</code> if you need access to the capture group
matches. Otherwise, <ahref="struct.Regex.html#method.find"title="method regex::bytes::Regex::find"><code>Regex::find</code></a> is generally faster for discovering
) -><aclass="struct"href="struct.CaptureMatches.html"title="struct regex::bytes::CaptureMatches">CaptureMatches</a><'r, 'h><ahref="#"class="tooltip"data-notable-ty="CaptureMatches<'r, 'h>">ⓘ</a></h4></section></summary><divclass="docblock"><p>Returns an iterator that yields successive non-overlapping matches in
the given haystack. The iterator yields values of type <ahref="struct.Captures.html"title="struct regex::bytes::Captures"><code>Captures</code></a>.</p>
<p>This is the same as <ahref="struct.Regex.html#method.find_iter"title="method regex::bytes::Regex::find_iter"><code>Regex::find_iter</code></a>, but instead of only providing
access to the overall match, each value yield includes access to the
matches of all capture groups in the regex. Reporting this extra match
data is potentially costly, so callers should only use <code>captures_iter</code>
over <code>find_iter</code> when they actually need access to the capture group
<spanclass="macro">assert_eq!</span>(<spanclass="kw-2">&</span>caps[<spanclass="string">"title"</span>], <spanclass="string">b"The Wizard of Oz"</span>);
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.split"class="method"><aclass="src rightside"href="../../src/regex/regex/bytes.rs.html#562-564">source</a><h4class="code-header">pub fn <ahref="#method.split"class="fn">split</a><'r, 'h>(&'r self, haystack: &'h [<aclass="primitive"href="https://doc.rust-lang.org/1.77.0/std/primitive.u8.html">u8</a>]) -><aclass="struct"href="struct.Split.html"title="struct regex::bytes::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 substrings of the haystack given, delimited by a
) -><aclass="struct"href="struct.SplitN.html"title="struct regex::bytes::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> substrings of the haystack
given, delimited by a match of the regex. (A <code>limit</code> of <code>0</code> will return
no substrings.) 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
) -><aclass="enum"href="https://doc.rust-lang.org/1.77.0/alloc/borrow/enum.Cow.html"title="enum alloc::borrow::Cow">Cow</a><'h, [<aclass="primitive"href="https://doc.rust-lang.org/1.77.0/std/primitive.u8.html">u8</a>]></h4></section></summary><divclass="docblock"><p>Replaces the leftmost-first match in the given haystack with the
<p>But anything satisfying the <ahref="trait.Replacer.html"title="trait regex::bytes::Replacer"><code>Replacer</code></a> trait will work. For example,
a closure of type <code>|&Captures| -> String</code> provides direct access to the
captures corresponding to a match. This allows one to access capturing
) -><aclass="enum"href="https://doc.rust-lang.org/1.77.0/alloc/borrow/enum.Cow.html"title="enum alloc::borrow::Cow">Cow</a><'h, [<aclass="primitive"href="https://doc.rust-lang.org/1.77.0/std/primitive.u8.html">u8</a>]></h4></section></summary><divclass="docblock"><p>Replaces all non-overlapping matches in the haystack with the
<p>The documentation for <ahref="struct.Regex.html#method.replace"title="method regex::bytes::Regex::replace"><code>Regex::replace</code></a> goes into more detail about
what kinds of replacement strings are supported.</p>
) -><aclass="enum"href="https://doc.rust-lang.org/1.77.0/alloc/borrow/enum.Cow.html"title="enum alloc::borrow::Cow">Cow</a><'h, [<aclass="primitive"href="https://doc.rust-lang.org/1.77.0/std/primitive.u8.html">u8</a>]></h4></section></summary><divclass="docblock"><p>Replaces at most <code>limit</code> non-overlapping matches in the haystack with
<p>The documentation for <ahref="struct.Regex.html#method.replace"title="method regex::bytes::Regex::replace"><code>Regex::replace</code></a> goes into more detail about
what kinds of replacement strings are supported.</p>
<p>See the corresponding section in the docs for <ahref="struct.Regex.html#method.replace_all"title="method regex::bytes::Regex::replace_all"><code>Regex::replace_all</code></a>
for tips on how to deal with a replacement routine that can fail.</p>
</div></details></div></details><detailsclass="toggle implementors-toggle"open><summary><sectionid="impl-Regex-1"class="impl"><aclass="src rightside"href="../../src/regex/regex/bytes.rs.html#981-1261">source</a><ahref="#impl-Regex-1"class="anchor">§</a><h3class="code-header">impl <aclass="struct"href="struct.Regex.html"title="struct regex::bytes::Regex">Regex</a></h3></section></summary><divclass="docblock"><p>A group of advanced or “lower level” search methods. Some methods permit
</div><divclass="impl-items"><detailsclass="toggle method-toggle"open><summary><sectionid="method.shortest_match"class="method"><aclass="src rightside"href="../../src/regex/regex/bytes.rs.html#1011-1013">source</a><h4class="code-header">pub fn <ahref="#method.shortest_match"class="fn">shortest_match</a>(&self, haystack: &[<aclass="primitive"href="https://doc.rust-lang.org/1.77.0/std/primitive.u8.html">u8</a>]) -><aclass="enum"href="https://doc.rust-lang.org/1.77.0/core/option/enum.Option.html"title="enum core::option::Option">Option</a><<aclass="primitive"href="https://doc.rust-lang.org/1.77.0/std/primitive.usize.html">usize</a>></h4></section></summary><divclass="docblock"><p>Returns the end byte offset of the first match in the haystack given.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.shortest_match_at"class="method"><aclass="src rightside"href="../../src/regex/regex/bytes.rs.html#1046-1054">source</a><h4class="code-header">pub fn <ahref="#method.shortest_match_at"class="fn">shortest_match_at</a>(&self, haystack: &[<aclass="primitive"href="https://doc.rust-lang.org/1.77.0/std/primitive.u8.html">u8</a>], start: <aclass="primitive"href="https://doc.rust-lang.org/1.77.0/std/primitive.usize.html">usize</a>) -><aclass="enum"href="https://doc.rust-lang.org/1.77.0/core/option/enum.Option.html"title="enum core::option::Option">Option</a><<aclass="primitive"href="https://doc.rust-lang.org/1.77.0/std/primitive.usize.html">usize</a>></h4></section></summary><divclass="docblock"><p>Returns the same as <code>shortest_match</code>, but starts the search at the
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.is_match_at"class="method"><aclass="src rightside"href="../../src/regex/regex/bytes.rs.html#1084-1086">source</a><h4class="code-header">pub fn <ahref="#method.is_match_at"class="fn">is_match_at</a>(&self, haystack: &[<aclass="primitive"href="https://doc.rust-lang.org/1.77.0/std/primitive.u8.html">u8</a>], start: <aclass="primitive"href="https://doc.rust-lang.org/1.77.0/std/primitive.usize.html">usize</a>) -><aclass="primitive"href="https://doc.rust-lang.org/1.77.0/std/primitive.bool.html">bool</a></h4></section></summary><divclass="docblock"><p>Returns the same as <ahref="struct.Regex.html#method.is_match"title="method regex::bytes::Regex::is_match"><code>Regex::is_match</code></a>, but starts the search at the
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.find_at"class="method"><aclass="src rightside"href="../../src/regex/regex/bytes.rs.html#1116-1123">source</a><h4class="code-header">pub fn <ahref="#method.find_at"class="fn">find_at</a><'h>(&self, haystack: &'h [<aclass="primitive"href="https://doc.rust-lang.org/1.77.0/std/primitive.u8.html">u8</a>], start: <aclass="primitive"href="https://doc.rust-lang.org/1.77.0/std/primitive.usize.html">usize</a>) -><aclass="enum"href="https://doc.rust-lang.org/1.77.0/core/option/enum.Option.html"title="enum core::option::Option">Option</a><<aclass="struct"href="struct.Match.html"title="struct regex::bytes::Match">Match</a><'h>></h4></section></summary><divclass="docblock"><p>Returns the same as <ahref="struct.Regex.html#method.find"title="method regex::bytes::Regex::find"><code>Regex::find</code></a>, but starts the search at the given
) -><aclass="enum"href="https://doc.rust-lang.org/1.77.0/core/option/enum.Option.html"title="enum core::option::Option">Option</a><<aclass="struct"href="struct.Captures.html"title="struct regex::bytes::Captures">Captures</a><'h>></h4></section></summary><divclass="docblock"><p>Returns the same as <ahref="struct.Regex.html#method.captures"title="method regex::bytes::Regex::captures"><code>Regex::captures</code></a>, but starts the search at the
) -><aclass="enum"href="https://doc.rust-lang.org/1.77.0/core/option/enum.Option.html"title="enum core::option::Option">Option</a><<aclass="struct"href="struct.Match.html"title="struct regex::bytes::Match">Match</a><'h>></h4></section></summary><divclass="docblock"><p>This is like <ahref="struct.Regex.html#method.captures"title="method regex::bytes::Regex::captures"><code>Regex::captures</code></a>, but writes the byte offsets of each
<p>A <ahref="struct.CaptureLocations.html"title="struct regex::bytes::CaptureLocations"><code>CaptureLocations</code></a> stores the same byte offsets as a <ahref="struct.Captures.html"title="struct regex::bytes::Captures"><code>Captures</code></a>,
but does <em>not</em> store a reference to the haystack. This makes its API
a bit lower level and less convenient. But in exchange, callers
may allocate their own <code>CaptureLocations</code> and reuse it for multiple
searches. This may be helpful if allocating a <code>Captures</code> shows up in a
profile as too costly.</p>
<p>To create a <code>CaptureLocations</code> value, use the
) -><aclass="enum"href="https://doc.rust-lang.org/1.77.0/core/option/enum.Option.html"title="enum core::option::Option">Option</a><<aclass="struct"href="struct.Match.html"title="struct regex::bytes::Match">Match</a><'h>></h4></section></summary><divclass="docblock"><p>Returns the same as <ahref="struct.Regex.html#method.captures_read"title="method regex::bytes::Regex::captures_read"><code>Regex::captures_read</code></a>, but starts the search at
</div><divclass="impl-items"><detailsclass="toggle method-toggle"open><summary><sectionid="method.as_str"class="method"><aclass="src rightside"href="../../src/regex/regex/bytes.rs.html#1276-1278">source</a><h4class="code-header">pub fn <ahref="#method.as_str"class="fn">as_str</a>(&self) ->&<aclass="primitive"href="https://doc.rust-lang.org/1.77.0/std/primitive.str.html">str</a></h4></section></summary><divclass="docblock"><p>Returns the original string of this regex.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.capture_names"class="method"><aclass="src rightside"href="../../src/regex/regex/bytes.rs.html#1326-1328">source</a><h4class="code-header">pub fn <ahref="#method.capture_names"class="fn">capture_names</a>(&self) -><aclass="struct"href="struct.CaptureNames.html"title="struct regex::bytes::CaptureNames">CaptureNames</a><'_><ahref="#"class="tooltip"data-notable-ty="CaptureNames<'_>">ⓘ</a></h4></section></summary><divclass="docblock"><p>Returns an iterator over the capture names in this regex.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.captures_len"class="method"><aclass="src rightside"href="../../src/regex/regex/bytes.rs.html#1357-1359">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.77.0/std/primitive.usize.html">usize</a></h4></section></summary><divclass="docblock"><p>Returns the number of captures groups in this regex.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.static_captures_len"class="method"><aclass="src rightside"href="../../src/regex/regex/bytes.rs.html#1397-1399">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.77.0/core/option/enum.Option.html"title="enum core::option::Option">Option</a><<aclass="primitive"href="https://doc.rust-lang.org/1.77.0/std/primitive.usize.html">usize</a>></h4></section></summary><divclass="docblock"><p>Returns the total number of capturing groups that appear in every
<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::bytes::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.capture_locations"class="method"><aclass="src rightside"href="../../src/regex/regex/bytes.rs.html#1419-1421">source</a><h4class="code-header">pub fn <ahref="#method.capture_locations"class="fn">capture_locations</a>(&self) -><aclass="struct"href="struct.CaptureLocations.html"title="struct regex::bytes::CaptureLocations">CaptureLocations</a></h4></section></summary><divclass="docblock"><p>Returns a fresh allocated set of capture locations that can
be reused in multiple calls to <ahref="struct.Regex.html#method.captures_read"title="method regex::bytes::Regex::captures_read"><code>Regex::captures_read</code></a> or
</div></details><detailsclass="toggle"open><summary><sectionid="associatedtype.Err"class="associatedtype trait-impl"><ahref="#associatedtype.Err"class="anchor">§</a><h4class="code-header">type <ahref="https://doc.rust-lang.org/1.77.0/core/str/traits/trait.FromStr.html#associatedtype.Err"class="associatedtype">Err</a> = <aclass="enum"href="../enum.Error.html"title="enum regex::Error">Error</a></h4></section></summary><divclass='docblock'>The associated error which can be returned from parsing.</div></details></div></details><detailsclass="toggle implementors-toggle"open><summary><sectionid="impl-TryFrom%3C%26str%3E-for-Regex"class="impl"><aclass="src rightside"href="../../src/regex/regex/bytes.rs.html#127-134">source</a><ahref="#impl-TryFrom%3C%26str%3E-for-Regex"class="anchor">§</a><h3class="code-header">impl <aclass="trait"href="https://doc.rust-lang.org/1.77.0/core/convert/trait.TryFrom.html"title="trait core::convert::TryFrom">TryFrom</a><&<aclass="primitive"href="https://doc.rust-lang.org/1.77.0/std/primitive.str.html">str</a>> for <aclass="struct"href="struct.Regex.html"title="struct regex::bytes::Regex">Regex</a></h3></section></summary><divclass="impl-items"><detailsclass="toggle method-toggle"open><summary><sectionid="method.try_from-1"class="method trait-impl"><aclass="src rightside"href="../../src/regex/regex/bytes.rs.html#131-133">source</a><ahref="#method.try_from-1"class="anchor">§</a><h4class="code-header">fn <ahref="https://doc.rust-lang.org/1.77.0/core/convert/trait.TryFrom.html#tymethod.try_from"class="fn">try_from</a>(s: &<aclass="primitive"href="https://doc.rust-lang.org/1.77.0/std/primitive.str.html">str</a>) -><aclass="enum"href="https://doc.rust-lang.org/1.77.0/core/result/enum.Result.html"title="enum core::result::Result">Result</a><<aclass="struct"href="struct.Regex.html"title="struct regex::bytes::Regex">Regex</a>, <aclass="enum"href="../enum.Error.html"title="enum regex::Error">Error</a>></h4></section></summary><divclass="docblock"><p>Attempts to parse a string into a regular expression</p>
</div></details><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.77.0/core/convert/trait.TryFrom.html#associatedtype.Error"class="associatedtype">Error</a> = <aclass="enum"href="../enum.Error.html"title="enum regex::Error">Error</a></h4></section></summary><divclass='docblock'>The type returned in the event of a conversion error.</div></details></div></details><detailsclass="toggle implementors-toggle"open><summary><sectionid="impl-TryFrom%3CString%3E-for-Regex"class="impl"><aclass="src rightside"href="../../src/regex/regex/bytes.rs.html#136-143">source</a><ahref="#impl-TryFrom%3CString%3E-for-Regex"class="anchor">§</a><h3class="code-header">impl <aclass="trait"href="https://doc.rust-lang.org/1.77.0/core/convert/trait.TryFrom.html"title="trait core::convert::TryFrom">TryFrom</a><<aclass="struct"href="https://doc.rust-lang.org/1.77.0/alloc/string/struct.String.html"title="struct alloc::string::String">String</a>> for <aclass="struct"href="struct.Regex.html"title="struct regex::bytes::Regex">Regex</a></h3></section></summary><divclass="impl-items"><detailsclass="toggle method-toggle"open><summary><sectionid="method.try_from"class="method trait-impl"><aclass="src rightside"href="../../src/regex/regex/bytes.rs.html#140-142">source</a><ahref="#method.try_from"class="anchor">§</a><h4class="code-header">fn <ahref="https://doc.rust-lang.org/1.77.0/core/convert/trait.TryFrom.html#tymethod.try_from"class="fn">try_from</a>(s: <aclass="struct"href="https://doc.rust-lang.org/1.77.0/alloc/string/struct.String.html"title="struct alloc::string::String">String</a>) -><aclass="enum"href="https://doc.rust-lang.org/1.77.0/core/result/enum.Result.html"title="enum core::result::Result">Result</a><<aclass="struct"href="struct.Regex.html"title="struct regex::bytes::Regex">Regex</a>, <aclass="enum"href="../enum.Error.html"title="enum regex::Error">Error</a>></h4></section></summary><divclass="docblock"><p>Attempts to parse a string into a regular expression</p>
</div></details><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.77.0/core/convert/trait.TryFrom.html#associatedtype.Error"class="associatedtype">Error</a> = <aclass="enum"href="../enum.Error.html"title="enum regex::Error">Error</a></h4></section></summary><divclass='docblock'>The type returned in the event of a conversion error.</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="trait"href="https://doc.rust-lang.org/1.77.0/core/panic/unwind_safe/trait.RefUnwindSafe.html"title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <aclass="struct"href="struct.Regex.html"title="struct regex::bytes::Regex">Regex</a></h3></section><sectionid="impl-Send-for-Regex"class="impl"><ahref="#impl-Send-for-Regex"class="anchor">§</a><h3class="code-header">impl <aclass="trait"href="https://doc.rust-lang.org/1.77.0/core/marker/trait.Send.html"title="trait core::marker::Send">Send</a> for <aclass="struct"href="struct.Regex.html"title="struct regex::bytes::Regex">Regex</a></h3></section><sectionid="impl-Sync-for-Regex"class="impl"><ahref="#impl-Sync-for-Regex"class="anchor">§</a><h3class="code-header">impl <aclass="trait"href="https://doc.rust-lang.org/1.77.0/core/marker/trait.Sync.html"title="trait core::marker::Sync">Sync</a> for <aclass="struct"href="struct.Regex.html"title="struct regex::bytes::Regex">Regex</a></h3></section><sectionid="impl-Unpin-for-Regex"class="impl"><ahref="#impl-Unpin-for-Regex"class="anchor">§</a><h3class="code-header">impl <aclass="trait"href="https://doc.rust-lang.org/1.77.0/core/marker/trait.Unpin.html"title="trait core::marker::Unpin">Unpin</a> for <aclass="struct"href="struct.Regex.html"title="struct regex::bytes::Regex">Regex</a></h3></section><sectionid="impl-UnwindSafe-for-Regex"class="impl"><ahref="#impl-UnwindSafe-for-Regex"class="anchor">§</a><h3class="code-header">impl <aclass="trait"href="https://doc.rust-lang.org/1.77.0/core/panic/unwind_safe/trait.UnwindSafe.html"title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <aclass="struct"href="struct.Regex.html"title="struct regex::bytes::Regex">Regex</a></h3></section></div><h2id="blanket-implementations"class="section-header">Blanket Implementations<ahref="#blanket-implementations"class="anchor">§</a></h2><divid="blanket-implementations-list"><detailsclass="toggle implementors-toggle"><summary><sectionid="impl-Any-for-T"class="impl"><aclass="src rightside"href="https://doc.rust-lang.org/1.77.0/src/core/any.rs.html#140">source</a><ahref="#impl-Any-for-T"class="anchor">§</a><h3class="code-header">impl<T><aclass="trait"href="https://doc.rust-lang.org/1.77.0/core/any/trait.Any.html"title="trait core::any::Any">Any</a> for T<divclass="where">where
<code><ahref="https://doc.rust-lang.org/1.77.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.77.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.77.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.77.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.77.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.77.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.77.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.77.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.77.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.77.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.77.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.77.0/alloc/borrow/trait.ToOwned.html#method.clone_into">Read more</a></div></details></div></details><detailsclass="toggle implementors-toggle"><summary><sectionid="impl-ToString-for-T"class="impl"><aclass="src rightside"href="https://doc.rust-lang.org/1.77.0/src/alloc/string.rs.html#2600">source</a><ahref="#impl-ToString-for-T"class="anchor">§</a><h3class="code-header">impl<T><aclass="trait"href="https://doc.rust-lang.org/1.77.0/alloc/string/trait.ToString.html"title="trait alloc::string::ToString">ToString</a> for T<divclass="where">where
T: <aclass="trait"href="https://doc.rust-lang.org/1.77.0/core/fmt/trait.Display.html"title="trait core::fmt::Display">Display</a> + ?<aclass="trait"href="https://doc.rust-lang.org/1.77.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.to_string"class="method trait-impl"><aclass="src rightside"href="https://doc.rust-lang.org/1.77.0/src/alloc/string.rs.html#2606">source</a><ahref="#method.to_string"class="anchor">§</a><h4class="code-header">default fn <ahref="https://doc.rust-lang.org/1.77.0/alloc/string/trait.ToString.html#tymethod.to_string"class="fn">to_string</a>(&self) -><aclass="struct"href="https://doc.rust-lang.org/1.77.0/alloc/string/struct.String.html"title="struct alloc::string::String">String</a></h4></section></summary><divclass='docblock'>Converts the given value to a <code>String</code>. <ahref="https://doc.rust-lang.org/1.77.0/alloc/string/trait.ToString.html#tymethod.to_string">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.77.0/src/core/convert/mod.rs.html#804-806">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.77.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.77.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-3"class="associatedtype trait-impl"><ahref="#associatedtype.Error-3"class="anchor">§</a><h4class="code-header">type <ahref="https://doc.rust-lang.org/1.77.0/core/convert/trait.TryFrom.html#associatedtype.Error"class="associatedtype">Error</a> = <aclass="enum"href="https://doc.rust-lang.org/1.77.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-2"class="method trait-impl"><aclass="src rightside"href="https://doc.rust-lang.org/1.77.0/src/core/convert/mod.rs.html#811">source</a><ahref="#method.try_from-2"class="anchor">§</a><h4class="code-header">fn <ahref="https://doc.rust-lang.org/1.77.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.77.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.77.0/core/convert/trait.TryFrom.html"title="trait core::convert::TryFrom">TryFrom</a><U>>::<aclass="associatedtype"href="https://doc.rust-lang.org/1.77.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.77.0/src/core/convert/mod.rs.html#789-791">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.77.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.77.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-2"class="associatedtype trait-impl"><ahref="#associatedtype.Error-2"class="anchor">§</a><h4class="code-header">type <ahref="https://doc.rust-lang.org/1.77.0/core/convert/trait.TryInto.html#associatedtype.Error"class="associatedtype">Error</a> = <U as <aclass="trait"href="https://doc.rust-lang.org/1.77.0/core/convert/trait.TryFrom.html"title="trait core::convert::TryFrom">TryFrom</a><T>>::<aclass="associatedtype"href="https://doc.rust-lang.org/1.77.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.77.0/src/core/convert/mod.rs.html#796">source</a><ahref="#method.try_into"class="anchor">§</a><h4class="code-header">fn <ahref="https://doc.rust-lang.org/1.77.0/core/convert/trait.TryInto.html#tymethod.try_into"class="fn">try_into</a>(self) -><aclass="enum"href="https://doc.rust-lang.org/1.77.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.77.0/core/convert/trait.TryFrom.html"title="trait core::convert::TryFrom">TryFrom</a><T>>::<aclass="associatedtype"href="https://doc.rust-lang.org/1.77.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">{"CaptureMatches<'r,'h>":"<h3>Notabletraitsfor<code><aclass=\"struct\"href=\"struct.CaptureMatches.html\"title=\"structregex::bytes::CaptureMatches\">CaptureMatches</a><'r,'h></code></h3><pre><code><divclass=\"where\">impl<'r,'h><aclass=\"trait\"href=\"https://doc.rust-lang.org/1.77.0/core/iter/traits/iterator/trait.Iterator.html\"title=\"traitcore::iter::traits::iterator::Iterator\">Iterator</a>for<aclass=\"struct\"href=\"struct.CaptureMatches.html\"title=\"structregex::bytes::CaptureMatches\">CaptureMatches</a><'r,'h></div><divclass=\"where\">type<ahref=\"https://doc.rust-lang.org/1.77.0/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item\"class=\"associatedtype\">Item</a>=<aclass=\"struct\"href=\"struct.Captures.html\"title=\"structregex::bytes::Captures\">Captures</a><'h>;</div>","CaptureNames<'_>":"<h3>Notabletraitsfor<code><aclass=\"struct\"href=\"struct.CaptureNames.html\"title=\"structregex::bytes::CaptureNames\">CaptureNames</a><'r></code></h3><pre><code><divclass=\"where\">impl<'r><aclass=\"trait\"href=\"https://doc.rust-lang.org/1.77.0/core/iter/traits/iterator/trait.Iterator.html\"title=\"traitcore::iter::traits::iterator::Iterator\">Iterator</a>for<aclass=\"struct\"href=\"struct.CaptureNames.html\"title=\"structregex::bytes::CaptureNames\">CaptureNames</a><'r></div><divclass=\"where\">type<ahref=\"https://doc.rust-lang.org/1.77.0/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item\"class=\"associatedtype\">Item</a>=<aclass=\"enum\"href=\"https://doc.rust-lang.org/1.77.0/core/option/enum.Option.html\"title=\"enumcore::option::Option\">Option</a><&'r<aclass=\"primitive\"href=\"https://doc.rust-lang.org/1.77.0/std/primitive.str.html\">str</a>>;</div>","Matches<'r,'h>":"<h3>Notabletraitsfor<code><aclass=\"struct\"href=\"struct.Matches.html\"title=\"structregex::bytes::Matches\">Matches</a><'r,'h></code></h3><pre><code><divclass=\"where\">impl<'r,'h&