mirror of
https://github.com/boostorg/regex.git
synced 2025-07-15 21:32:18 +02:00
Added docs for smatch and wsmatch typedefs, added warnings about using temporaries with regex_search/regex_match.
[SVN r11383]
This commit is contained in:
@ -158,12 +158,14 @@ result of a match contains a number of sub-expression matches in
|
||||
addition to the overall match. When the library needs to report a
|
||||
regular expression match it does so using an instance of the
|
||||
class <a href="template_class_ref.htm#reg_match">match_results</a>,
|
||||
as before there are typedefs of this class for the two most
|
||||
common cases: </p>
|
||||
as before there are typedefs of this class for the most common
|
||||
cases: </p>
|
||||
|
||||
<pre><b>namespace </b>boost{
|
||||
<b>typedef</b> match_results<<b>const</b> <b>char</b>*> cmatch;
|
||||
<b>typedef</b> match_results<<b>const</b> <b>wchar_t</b>*> wcmatch;
|
||||
<strong>typedef</strong> match_results<std::string::const_iterator> smatch;
|
||||
<strong>typedef</strong> match_results<std::wstring::const_iterator> wsmatch;
|
||||
}</pre>
|
||||
|
||||
<p>The algorithms <a href="template_class_ref.htm#reg_search">regex_search</a>
|
||||
|
@ -871,7 +871,9 @@ each sub-expression match being contained in an object of type <i>sub_match</i>.
|
||||
<b>bool</b> <b>operator</b><(<b>const</b> match_results& that)<b>const</b>;
|
||||
};
|
||||
<strong>typedef</strong> match_results<<strong>const</strong> <strong>char</strong>*> cmatch;
|
||||
<strong>typedef</strong> match_results<<strong>const</strong> <strong>wchar_t</strong>*> wcmatch; </pre>
|
||||
<strong>typedef</strong> match_results<<strong>const</strong> <strong>wchar_t</strong>*> wcmatch;
|
||||
<strong>typedef</strong> match_results<std::string::const_iterator> smatch;
|
||||
<strong>typedef</strong> match_results<std::wstring::const_iterator> wsmatch; </pre>
|
||||
|
||||
<p>Class match_results is used for reporting what matched a
|
||||
regular expression, it is passed to the matching algorithms <a
|
||||
@ -1128,10 +1130,10 @@ properties. </p>
|
||||
|
||||
<p>The algorithm regex _match determines whether a given regular
|
||||
expression matches a given sequence denoted by a pair of
|
||||
bidirectional-iterators, the algorithm is defined as follows,
|
||||
note that the result is true only if the expression matches the
|
||||
whole of the input sequence, the main use of this function is
|
||||
data input validation: </p>
|
||||
bidirectional-iterators, the algorithm is defined as follows, <em>note
|
||||
that the result is true only if the expression matches the whole
|
||||
of the input sequence</em>, the main use of this function is data
|
||||
input validation: </p>
|
||||
|
||||
<pre><b>template</b> <<b>class</b> iterator, <b>class</b> Allocator, <b>class</b> charT, <b>class</b> traits, <b>class</b> Allocator2>
|
||||
<b>bool</b> regex_match(iterator first,
|
||||
@ -1205,7 +1207,12 @@ return true or false and do not indicate what matched: </p>
|
||||
will be less than or equal to last. m[1] denotes the
|
||||
first subexpression m[2] the second subexpression and so
|
||||
on. If no match occurred then m[0].first = m[0].second =
|
||||
last.</td>
|
||||
last.<p>Note that since the match_results structure
|
||||
stores only iterators, and not strings, the iterators/strings
|
||||
passed to regex_match must be valid for as long as the
|
||||
result is to be used. For that reason never pass
|
||||
temporary string objects to regex_match.</p>
|
||||
</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -1456,7 +1463,13 @@ upon your compilers capabilities]: </p>
|
||||
that matched, m[0].first and m[0].second will be less
|
||||
than or equal to last. m[1] denotes the first sub-expression
|
||||
m[2] the second sub-expression and so on. If no match
|
||||
occurred then m[0].first = m[0].second = last.</td>
|
||||
occurred then m[0].first = m[0].second = last.<p>Note
|
||||
that since the match_results structure stores only
|
||||
iterators, and not strings, the iterators/strings passed
|
||||
to regex_search must be valid for as long as the result
|
||||
is to be used. For that reason never pass temporary
|
||||
string objects to regex_search.</p>
|
||||
</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
Reference in New Issue
Block a user