Files
hustoj/web/cppreference-zh/chmhelp/cpp-regex-basic_regex-assign.html
2025-08-01 12:57:54 +08:00

158 lines
12 KiB
HTML

<!DOCTYPE html>
<html lang="zh" dir="ltr" class="client-nojs" xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh">
<head><meta http-equiv="x-ua-compatible" content="ie=edge">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>std::basic_regex&lt;CharT,Traits&gt;::assign</title>
<link rel="stylesheet" href="ext.css" />
<link rel="stylesheet" href="site_modules.css" />
</head>
<body class="mediawiki ltr sitedir-ltr ns-0 ns-subject page-cpp_regex_basic_regex_assign skin-cppreference2 action-view cpp-navbar">
<div id="cpp-content-base">
<div id="content"><a id="top"></a>
<h1 id="firstHeading" class="firstHeading"><span style="font-size:0.7em; line-height:130%">std::basic_regex&lt;CharT,Traits&gt;::</span>assign</h1>
<div id="bodyContent">
<div id="contentSub"><span class="subpages">&lt; <a href="cpp.html">cpp</a>&lrm; | <a href="cpp-regex.html">regex</a>&lrm; | <a href="cpp-regex-basic_regex.html">basic regex</a></span></div>
<div id="mw-content-text" lang="zh" dir="ltr" class="mw-content-ltr" xml:lang="zh">
<table class="t-dcl-begin">
<tbody>
<tr class="t-dcl t-since-cxx11">
<td>
<div><span class="mw-geshi cpp source-cpp">basic_regex<span class="sy3">&amp;</span> assign<span class="br0">(</span> <span class="kw4">const</span> basic_regex<span class="sy3">&amp;</span> other <span class="br0">)</span><span class="sy4">;</span></span></div>
</td>
<td>(1)</td>
<td><span class="t-mark-rev t-since-cxx11">(C++11 &#36215;)</span></td>
</tr>
<tr class="t-dcl t-since-cxx11">
<td>
<div><span class="mw-geshi cpp source-cpp">basic_regex<span class="sy3">&amp;</span> assign<span class="br0">(</span> basic_regex<span class="sy3">&amp;&amp;</span> that <span class="br0">)</span> <span class="kw1">noexcept</span><span class="sy4">;</span></span></div>
</td>
<td>(2)</td>
<td><span class="t-mark-rev t-since-cxx11">(C++11 &#36215;)</span></td>
</tr>
<tr class="t-dcl t-since-cxx11">
<td>
<div><span class="mw-geshi cpp source-cpp">basic_regex<span class="sy3">&amp;</span> assign<span class="br0">(</span> <span class="kw4">const</span> CharT<span class="sy2">*</span> s,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;flag_type f <span class="sy1">=</span> <a href="cpp-regex-syntax_option_type.html"><span class="kw2032">std::<span class="me2">regex_constants</span><span class="sy4">::</span><span class="me2">ECMAScript</span></span></a> <span class="br0">)</span><span class="sy4">;</span></span></div>
</td>
<td>(3)</td>
<td><span class="t-mark-rev t-since-cxx11">(C++11 &#36215;)</span></td>
</tr>
<tr class="t-dcl t-since-cxx11">
<td>
<div><span class="mw-geshi cpp source-cpp">basic_regex<span class="sy3">&amp;</span> assign<span class="br0">(</span> <span class="kw4">const</span> CharT<span class="sy2">*</span> ptr, size_t count,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;flag_type f <span class="sy1">=</span> <a href="cpp-regex-syntax_option_type.html"><span class="kw2032">std::<span class="me2">regex_constants</span><span class="sy4">::</span><span class="me2">ECMAScript</span></span></a> <span class="br0">)</span><span class="sy4">;</span></span></div>
</td>
<td>(4)</td>
<td><span class="t-mark-rev t-since-cxx11">(C++11 &#36215;)</span></td>
</tr>
<tr class="t-dcl t-since-cxx11">
<td>
<div><span class="mw-geshi cpp source-cpp"><span class="kw1">template</span><span class="sy1">&lt;</span> <span class="kw1">class</span> ST, <span class="kw1">class</span> SA <span class="sy1">&gt;</span><br /></span>
<p>basic_regex<span class="sy3">&amp;</span> assign<span class="br0">(</span> <span class="kw4">const</span> <a href="cpp-string-basic_string.html"><span class="kw1228">std::<span class="me2">basic_string</span></span></a><span class="sy1">&lt;</span>CharT,ST,SA<span class="sy1">&gt;</span><span class="sy3">&amp;</span> str,<br /></p>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;flag_type f <span class="sy1">=</span> <a href="cpp-regex-syntax_option_type.html"><span class="kw2032">std::<span class="me2">regex_constants</span><span class="sy4">::</span><span class="me2">ECMAScript</span></span></a> <span class="br0">)</span><span class="sy4">;</span></div>
</td>
<td>(5)</td>
<td><span class="t-mark-rev t-since-cxx11">(C++11 &#36215;)</span></td>
</tr>
<tr class="t-dcl t-since-cxx11">
<td>
<div><span class="mw-geshi cpp source-cpp"><span class="kw1">template</span><span class="sy1">&lt;</span> <span class="kw1">class</span> InputIt <span class="sy1">&gt;</span><br /></span>
<p>basic_regex<span class="sy3">&amp;</span> assign<span class="br0">(</span> InputIt first, InputIt last,<br /></p>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;flag_type f <span class="sy1">=</span> <a href="cpp-regex-syntax_option_type.html"><span class="kw2032">std::<span class="me2">regex_constants</span><span class="sy4">::</span><span class="me2">ECMAScript</span></span></a> <span class="br0">)</span><span class="sy4">;</span></div>
</td>
<td>(6)</td>
<td><span class="t-mark-rev t-since-cxx11">(C++11 &#36215;)</span></td>
</tr>
<tr class="t-dcl t-since-cxx11">
<td>
<div><span class="mw-geshi cpp source-cpp">basic_regex<span class="sy3">&amp;</span> assign<span class="br0">(</span> <a href="cpp-utility-initializer_list.html"><span class="kw960">std::<span class="me2">initializer_list</span></span></a><span class="sy1">&lt;</span>CharT<span class="sy1">&gt;</span> ilist,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;flag_type f <span class="sy1">=</span> <a href="cpp-regex-syntax_option_type.html"><span class="kw2032">std::<span class="me2">regex_constants</span><span class="sy4">::</span><span class="me2">ECMAScript</span></span></a> <span class="br0">)</span><span class="sy4">;</span></span></div>
</td>
<td>(7)</td>
<td><span class="t-mark-rev t-since-cxx11">(C++11 &#36215;)</span></td>
</tr>
<tr class="t-dcl-sep">
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<p>&#36171;&#20540;&#20869;&#23481;&#32473;&#27491;&#21017;&#34920;&#36798;&#24335;&#12290;</p>
<div class="t-li1"><span class="t-li">1)</span> &#36171;&#20540; <code>other</code> &#30340;&#20869;&#23481;&#12290;&#35843;&#29992;&#21518; <span class="t-lc"><a href="cpp-regex-basic_regex-flags.html">flags()</a></span> &#21644; <span class="t-lc"><a href="cpp-regex-basic_regex-mark_count.html">mark_count()</a></span> &#31561;&#20110; <span class="t-c"><span class="mw-geshi cpp source-cpp">other.<span class="me1">flags</span><span class="br0">(</span><span class="br0">)</span></span></span> &#21644; <span class="t-c"><span class="mw-geshi cpp source-cpp">other.<span class="me1">mark_count</span><span class="br0">(</span><span class="br0">)</span></span></span> &#30340;&#20540;&#12290;</div>
<div class="t-li1"><span class="t-li">2)</span> &#29992;&#31227;&#21160;&#35821;&#20041;&#36171;&#20540; <code>other</code> &#30340;&#20869;&#23481;&#12290; <span class="t-lc"><a href="cpp-regex-basic_regex-flags.html">flags()</a></span> &#21644; <span class="t-lc"><a href="cpp-regex-basic_regex-mark_count.html">mark_count()</a></span> &#31561;&#20110; <span class="t-c"><span class="mw-geshi cpp source-cpp">other.<span class="me1">flags</span><span class="br0">(</span><span class="br0">)</span></span></span> &#21644; <span class="t-c"><span class="mw-geshi cpp source-cpp">other.<span class="me1">mark_count</span><span class="br0">(</span><span class="br0">)</span></span></span> &#22312;&#36171;&#20540;&#21069;&#30340;&#20540;&#12290;&#35843;&#29992;&#21518;&#65292; <code>other</code> &#22312;&#21512;&#27861;&#20294;&#26410;&#25351;&#23450;&#30340;&#29366;&#24577;&#12290;</div>
<div class="t-li1"><span class="t-li">3-7)</span> &#36171;&#20540;&#23383;&#31526;&#24207;&#21015;&#32473;&#27491;&#21017;&#34920;&#36798;&#24335;&#12290;&#35774;&#32622;&#35821;&#27861;&#26631;&#24535;&#20026; <code>f</code> &#12290;&#35843;&#29992;&#21518; <span class="t-lc"><a href="cpp-regex-basic_regex-mark_count.html">mark_count()</a></span> &#20135;&#29983;&#30340;&#23376;&#34920;&#36798;&#24335;&#20013;&#30340;&#26377;&#26631;&#35760;&#23376;&#34920;&#36798;&#24335;&#25968;&#12290;</div>
<div class="t-li2"><span class="t-li">3)</span> &#36171;&#20540; <code>s</code> &#25152;&#25351;&#21521;&#30340;&#31354;&#32456;&#27490;&#23383;&#31526;&#20018;&#12290;</div>
<div class="t-li2"><span class="t-li">4)</span> &#36171;&#20540; <code>s</code> &#25152;&#25351;&#21521;&#30340; <code>count</code> &#20010;&#23383;&#31526;&#24207;&#21015;&#12290;</div>
<div class="t-li2"><span class="t-li">5)</span> &#36171;&#20540; string <code>str</code> &#12290;</div>
<div class="t-li2"><span class="t-li">6)</span> &#36171;&#20540;&#33539;&#22260; <code>[first, last)</code> &#20013;&#30340;&#23383;&#31526;&#12290;</div>
<div class="t-li2"><span class="t-li">7)</span> &#36171;&#20540; initializer_list <code>ilist</code> &#20013;&#30340;&#23383;&#31526;&#12290;</div>
<h3><span class="mw-headline" id=".E5.8F.82.E6.95.B0">&#21442;&#25968;</span></h3>
<table class="t-par-begin">
<tr class="t-par">
<td>other</td>
<td>-</td>
<td>&#35201;&#36171;&#20540;&#30340;&#21478;&#19968;&#27491;&#21017;&#34920;&#36798;&#24335;</td>
</tr>
<tr class="t-par">
<td>s</td>
<td>-</td>
<td>&#25351;&#21521;&#35201;&#36171;&#20540;&#30340;&#23383;&#31526;&#24207;&#21015;&#30340;&#25351;&#38024;</td>
</tr>
<tr class="t-par">
<td>str</td>
<td>-</td>
<td>&#35201;&#36171;&#20540;&#30340; string</td>
</tr>
<tr class="t-par">
<td>first, last</td>
<td>-</td>
<td>&#35201;&#36171;&#20540;&#30340;&#23383;&#31526;&#33539;&#22260;</td>
</tr>
<tr class="t-par">
<td>ilist</td>
<td>-</td>
<td>&#21547;&#35201;&#36171;&#20540;&#30340;&#23383;&#31526;&#30340; initializer_list</td>
</tr>
<tr class="t-par-hitem">
<td colspan="3">&#31867;&#22411;&#35201;&#27714;</td>
</tr>
<tr class="t-par-req">
<td colspan="3">-
<div class="spacer"></div>
<code>InputIt</code> &#24517;&#39035;&#28385;&#36275;<a href="cpp-named_req-InputIterator.html"><span style="font-style:italic">&#32769;&#24335;&#36755;&#20837;&#36845;&#20195;&#22120;</span> <span style="font-family: Georgia, &#39;DejaVu Serif&#39;, serif; font-style:italic">(LegacyInputIterator)</span></a> &#30340;&#35201;&#27714;&#12290;</td>
</tr>
</table>
<h3><span class="mw-headline" id=".E8.BF.94.E5.9B.9E.E5.80.BC">&#36820;&#22238;&#20540;</span></h3>
<p><span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="sy2">*</span>this</span></span></p>
<h3><span class="mw-headline" id=".E5.BC.82.E5.B8.B8">&#24322;&#24120;</span></h3>
<div class="t-li1"><span class="t-li">1)</span> &#21487;&#33021;&#25243;&#20986;&#23454;&#29616;&#23450;&#20041;&#30340;&#24322;&#24120;&#12290;</div>
<div class="t-li1"><span class="t-li">3-7)</span> &#33509;&#25552;&#20379;&#30340;&#27491;&#21017;&#34920;&#36798;&#24335;&#38750;&#27861;&#21017;&#20026; <span class="t-lc"><a href="cpp-regex-regex_error.html">std::regex_error</a></span> &#12290;&#35813;&#24773;&#20917;&#19979;&#19981;&#20462;&#25913;&#23545;&#35937;&#12290;</div>
<h3><span class="mw-headline" id=".E7.A4.BA.E4.BE.8B">&#31034;&#20363;</span></h3>
<table class="metadata plainlinks ambox mbox-small-left ambox-notice" style="">
<tr>
<td class="mbox-empty-cell"></td>
<td class="mbox-text" style="">&#26412;&#33410;&#26410;&#23436;&#25104;<br />
&#21407;&#22240;&#65306;&#26242;&#26080;&#31034;&#20363;</td>
</tr>
</table>
<h3><span class="mw-headline" id=".E5.8F.82.E9.98.85">&#21442;&#38405;</span></h3>
<table class="t-dsc-begin">
<tr class="t-dsc">
<td>
<div class="t-dsc-member-div">
<div><a href="cpp-regex-basic_regex-operator=.html"><span class="t-lines"><span>operator=</span></span></a></div>
</div>
</td>
<td>&#36171;&#20540;&#20869;&#23481;<br />
<span class="t-mark">(&#20844;&#24320;&#25104;&#21592;&#20989;&#25968;)</span></td>
</tr>
</table>
</div>
<div class="visualClear"></div>
</div>
</div>
</div>
</body>
</html>