Added new experimental captures support.

[SVN r21243]
This commit is contained in:
John Maddock
2003-12-13 12:28:48 +00:00
parent 6b95ac002e
commit bf9350aa16
28 changed files with 1593 additions and 612 deletions

250
doc/Attic/captures.html Normal file
View File

@ -0,0 +1,250 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Index</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">Understanding Captures</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<H2>Marked sub-expressions</H2>
<P>Every time a Perl regular expression contains a parenthesis group (), it spits
out an extra field, known as a marked sub-expression, for example the
expression:</P>
<PRE>(\w+)\W+(\w+)</PRE>
<P>
Has two marked sub-expressions (known as $1 and $2 respectively), in addition
the complete match is known as $&amp;, everything before the first match as $`,
and everything after the match as $'.&nbsp; So if the above expression is
searched for within "@abc def--", then we obtain:</P>
<BLOCKQUOTE dir="ltr" style="MARGIN-RIGHT: 0px">
<P>
<TABLE id="Table2" cellSpacing="1" cellPadding="1" width="300" border="0">
<TR>
<TD>
<P dir="ltr" style="MARGIN-RIGHT: 0px">$`</P>
</TD>
<TD>"@"</TD>
</TR>
<TR>
<TD>$&amp;</TD>
<TD>"abc def"</TD>
</TR>
<TR>
<TD>$1</TD>
<TD>"abc"</TD>
</TR>
<TR>
<TD>$2</TD>
<TD>"def"</TD>
</TR>
<TR>
<TD>$'</TD>
<TD>"--"</TD>
</TR>
</TABLE>
</P>
</BLOCKQUOTE>
<P>In Boost.regex all these are accessible via the <A href="match_results.html">match_results</A>
class that gets filled in when calling one of the matching algorithms (<A href="regex_search.html">regex_search</A>,
<A href="regex_match.html">regex_match</A>, or <A href="regex_iterator.html">regex_iterator</A>).&nbsp;
So given:</P>
<PRE>boost::match_results&lt;IteratorType&gt; m;</PRE>
<P>The Perl and Boost.Regex equivalents are as follows:</P>
<BLOCKQUOTE dir="ltr" style="MARGIN-RIGHT: 0px">
<P>
<TABLE id="Table3" cellSpacing="1" cellPadding="1" width="300" border="0">
<TR>
<TD><STRONG>Perl</STRONG></TD>
<TD><STRONG>Boost.Regex</STRONG></TD>
</TR>
<TR>
<TD>$`</TD>
<TD>m.prefix()</TD>
</TR>
<TR>
<TD>$&amp;</TD>
<TD>m[0]</TD>
</TR>
<TR>
<TD>$n</TD>
<TD>m[n]</TD>
</TR>
<TR>
<TD>$'</TD>
<TD>m.suffix()</TD>
</TR>
</TABLE>
</P>
</BLOCKQUOTE>
<P>
<P>In Boost.Regex each sub-expression match is represented by a <A href="sub_match.html">
sub_match</A> object, this is basically just a pair of iterators denoting
the start and end possition of the sub-expression match, but there are some
additional operators provided so that objects of type sub_match behave a lot
like a std::basic_string: for example they are implicitly <A href="sub_match.html#m3">
convertible to a basic_string</A>, they can be <A href="sub_match.html#o21">compared
to a string</A>, <A href="sub_match.html#o81">added to a string</A>, or <A href="sub_match.html#oi">
streamed out to an output stream</A>.</P>
<H2>Unmatched Sub-Expressions</H2>
<P>When a regular expression match is found there is no need for all of the marked
sub-expressions to have participated in the match, for example the expression:</P>
<P>(abc)|(def)</P>
<P>can match either $1 or $2, but never both at the same time.&nbsp; In
Boost.Regex you can determine which sub-expressions matched by accessing the <A href="sub_match.html#m1">
sub_match::matched</A> data member.</P>
<H2>Repeated Captures</H2>
<P>When a marked sub-expression is repeated, then the sub-expression gets
"captured" multiple times, however normally only the final capture is
available, for example if</P>
<PRE>(?:(\w+)\W+)+</PRE>
<P>is matched against</P>
<PRE>one fine day</PRE>
<P>Then $1 will contain the string "day", and all the previous captures will have
been forgotten.</P>
<P>However, Boost.Regex has an experimental feature that allows all the capture
information to be retained - this is accessed either via the <A href="match_results.html#m17">
match_results::captures</A> member function or the <A href="sub_match.html#m8">sub_match::captures</A>
member function.&nbsp; These functions return a container that contains a
sequence of all the captures obtained during the regular expression
matching.&nbsp; The following example program shows how this information may be
used:</P>
<PRE>#include &lt;boost/regex.hpp&gt;
#include &lt;iostream&gt;
void print_captures(const std::string&amp; regx, const std::string&amp; text)
{
boost::regex e(regx);
boost::smatch what;
std::cout &lt;&lt; "Expression: \"" &lt;&lt; regx &lt;&lt; "\"\n";
std::cout &lt;&lt; "Text: \"" &lt;&lt; text &lt;&lt; "\"\n";
if(boost::regex_match(text, what, e, boost::match_extra))
{
unsigned i, j;
std::cout &lt;&lt; "** Match found **\n Sub-Expressions:\n";
for(i = 0; i &lt; what.size(); ++i)
std::cout &lt;&lt; " $" &lt;&lt; i &lt;&lt; " = \"" &lt;&lt; what[i] &lt;&lt; "\"\n";
std::cout &lt;&lt; " Captures:\n";
for(i = 0; i &lt; what.size(); ++i)
{
std::cout &lt;&lt; " $" &lt;&lt; i &lt;&lt; " = {";
for(j = 0; j &lt; what.captures(i).size(); ++j)
{
if(j)
std::cout &lt;&lt; ", ";
else
std::cout &lt;&lt; " ";
std::cout &lt;&lt; "\"" &lt;&lt; what.captures(i)[j] &lt;&lt; "\"";
}
std::cout &lt;&lt; " }\n";
}
}
else
{
std::cout &lt;&lt; "** No Match found **\n";
}
}
int main(int , char* [])
{
print_captures("(([[:lower:]]+)|([[:upper:]]+))+", "aBBcccDDDDDeeeeeeee");
print_captures("(.*)bar|(.*)bah", "abcbar");
print_captures("(.*)bar|(.*)bah", "abcbah");
print_captures("^(?:(\\w+)|(?&gt;\\W+))*$", "now is the time for all good men to come to the aid of the party");
return 0;
}</PRE>
<P>Which produces the following output:</P>
<PRE>Expression: "(([[:lower:]]+)|([[:upper:]]+))+"
Text: "aBBcccDDDDDeeeeeeee"
** Match found **
Sub-Expressions:
$0 = "aBBcccDDDDDeeeeeeee"
$1 = "eeeeeeee"
$2 = "eeeeeeee"
$3 = "DDDDD"
Captures:
$0 = { "aBBcccDDDDDeeeeeeee" }
$1 = { "a", "BB", "ccc", "DDDDD", "eeeeeeee" }
$2 = { "a", "ccc", "eeeeeeee" }
$3 = { "BB", "DDDDD" }
Expression: "(.*)bar|(.*)bah"
Text: "abcbar"
** Match found **
Sub-Expressions:
$0 = "abcbar"
$1 = "abc"
$2 = ""
Captures:
$0 = { "abcbar" }
$1 = { "abc" }
$2 = { }
Expression: "(.*)bar|(.*)bah"
Text: "abcbah"
** Match found **
Sub-Expressions:
$0 = "abcbah"
$1 = ""
$2 = "abc"
Captures:
$0 = { "abcbah" }
$1 = { }
$2 = { "abc" }
Expression: "^(?:(\w+)|(?&gt;\W+))*$"
Text: "now is the time for all good men to come to the aid of the party"
** Match found **
Sub-Expressions:
$0 = "now is the time for all good men to come to the aid of the party"
$1 = "party"
Captures:
$0 = { "now is the time for all good men to come to the aid of the party" }
$1 = { "now", "is", "the", "time", "for", "all", "good", "men", "to", "come", "to", "the", "aid", "of", "the", "party" }
</PRE>
<P>Unfortunately enabling this feature has an impact on performance (even if you
don't use it), and a much bigger impact if you do use it, therefore to use this
feature you need to:</P>
<UL>
<LI>
Define BOOST_REGEX_MATCH_EXTRA for all translation units including the library
source (the best way to do this is to uncomment this define in <A href="../../../boost/regex/user.hpp">
boost/regex/user.hpp</A>
and then rebuild everything.
<LI>
Pass the <A href="match_flag_type.html">match_extra flag</A> to the particular
algorithms where you actually need the captures information (<A href="regex_search.html">regex_search</A>,
<A href="regex_match.html">regex_match</A>, or <A href="regex_iterator.html">regex_iterator</A>).
</LI>
</UL>
<P>
<HR>
<P></P>
<P></P>
<p>Revised&nbsp;
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
12&nbsp;Dec 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
<p><i><EFBFBD> Copyright John Maddock&nbsp;
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
<P><I>Use, modification and distribution are subject to the Boost Software License,
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
</body>
</html>

View File

@ -46,6 +46,7 @@ static const match_flag_type match_any;
static const match_flag_type match_not_null;
static const match_flag_type match_continuous;
static const match_flag_type match_partial;
static const match_flag_type match_single_line;
static const match_flag_type match_prev_avail;
static const match_flag_type match_not_dot_newline;
static const match_flag_type match_not_dot_null;
@ -167,6 +168,20 @@ static const match_flag_type format_all;
in a full match.</p>
</td>
</tr>
<TR>
<TD vAlign="top" width="50%">match_extra</TD>
<TD vAlign="top" width="50%">Instructs the matching engine to retain all available <A href="captures.html">
capture</A> information; if a capturing group is repeated then information
about every repeat is available via <A href="match_results.html#m17">match_results::captures()</A>
or <A href="sub_match.html#m8">sub_match_captures().</A></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">match_single_line</TD>
<TD vAlign="top" width="50%">Equivalent to Perl's s/ modifier; prevents ^ from
matching after an embedded newline character (so that it only matches at the
start of the text being matched), and $ from matching before an embedded
newline (so that it only matches at the end of the text being matched).</TD>
</TR>
<tr>
<td valign="top" width="50%">
<p>match_prev_avail</p>
@ -259,8 +274,7 @@ static const match_flag_type format_all;
24 Oct 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
<p><i><EFBFBD> Copyright John Maddock&nbsp;1998-
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
<P><I>Use, modification and distribution are subject to the Boost Software License,
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>

View File

@ -2,23 +2,22 @@
<html>
<head>
<title>Boost.Regex: class match_results</title>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta content="HTML Tidy, see www.w3.org" name="generator">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<LINK href="../../../boost.css" type="text/css" rel="stylesheet"></head>
<body>
<p></p>
<table id="Table1" cellspacing="1" cellpadding="1" width="100%" border="0">
<table id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<tr>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
<td vAlign="top" width="300">
<h3><A href="../../../index.htm"><IMG height="86" alt="C++ Boost" src="../../../c++boost.gif" width="277" border="0"></A></h3>
</td>
<td width="353">
<h1 align="center">Boost.Regex</h1>
<h2 align="center">class match_results</h2>
</td>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
<h3><A href="index.html"><IMG height="45" alt="Boost.Regex Index" src="uarrow.gif" width="43" border="0"></A></h3>
</td>
</tr>
</table>
@ -27,23 +26,23 @@
<hr>
<h3>Contents</h3>
<dl class="index">
<dt><a href="#synopsis">Synopsis</a> <dt><a href="#description">Description</a></dt>
<dt><A href="#synopsis">Synopsis</A> <dt><A href="#description">Description</A> </dt>
</dl>
<h3><a name="synopsis"></a>Synopsis</h3>
<p>#include &lt;<a href="../../../boost/regex.hpp">boost/regex.hpp</a>&gt;</p>
<p>#include &lt;<A href="../../../boost/regex.hpp">boost/regex.hpp</A>&gt;</p>
<p>Regular expressions are different from many simple pattern-matching algorithms
in that as well as finding an overall match they can also produce
sub-expression matches: each sub-expression being delimited in the pattern by a
pair of parenthesis (...). There has to be some method for reporting
sub-expression matches back to the user: this is achieved this by defining a
class <i>match_results</i> that acts as an indexed collection of sub-expression
matches, each sub-expression match being contained in an object of type <i><a href="sub_match.html">
sub_match</a></i> .</p>
matches, each sub-expression match being contained in an object of type <i><A href="sub_match.html">
sub_match</A></i> .</p>
<p>Template class match_results denotes a collection of character sequences
representing the result of a regular expression match. Objects of type
match_results are passed to the algorithms <a href="regex_match.html">regex_match</a>
and <a href="regex_search.html">regex_search</a>, and are returned by the
iterator <a href="regex_iterator.html">regex_iterator</a> .&nbsp; Storage for
match_results are passed to the algorithms <A href="regex_match.html">regex_match</A>
and <A href="regex_search.html">regex_search</A>, and are returned by the
iterator <A href="regex_iterator.html">regex_iterator</A> .&nbsp; Storage for
the collection is allocated and freed as necessary by the member functions of
class match_results.</p>
<p>The template class match_results conforms to the requirements of a Sequence, as
@ -51,8 +50,7 @@
const-qualified Sequences are supported.</p>
<p>Class template match_results is most commonly used as one of the typedefs
cmatch, wcmatch, smatch, or wsmatch:</p>
<pre>
template &lt;class BidirectionalIterator,
<pre>template &lt;class BidirectionalIterator,
class Allocator = allocator&lt;sub_match&lt;BidirectionalIterator&gt; &gt;
class match_results;
@ -78,52 +76,58 @@ public:
typedef basic_string&lt;char_type&gt; string_type;
// construct/copy/destroy:
explicit <A href="#c1">match_results</A>(const Allocator&amp; a = Allocator());
<A href="#c2">match_results</A>(const match_results&amp; m);
<A href="#c3">match_results</A>&amp; <A href="#c3">operator</A>=(const match_results&amp; m);
explicit <A href="#c1" >match_results</A>(const Allocator&amp; a = Allocator());
<A href="#c2" >match_results</A>(const match_results&amp; m);
<A href="#c3" >match_results</A>&amp; <A href="#c3" >operator</A>=(const match_results&amp; m);
~match_results();
// size:
size_type <A href="#m1">size</A>() const;
size_type <A href="#m2">max_size</A>() const;
bool <A href="#m3">empty</A>() const;
size_type <A href="#m1" >size</A>() const;
size_type <A href="#m2" >max_size</A>() const;
bool <A href="#m3" >empty</A>() const;
// element access:
difference_type <A href="#m4">length</A>(int sub = 0) const;
difference_type <A href="#m5">position</A>(unsigned int sub = 0) const;
string_type <A href="#m6">str</A>(int sub = 0) const;
const_reference <A href="#m7">operator</A>[](int n) const;
difference_type <A href="#m4" >length</A>(int sub = 0) const;
difference_type <A href="#m5" >position</A>(unsigned int sub = 0) const;
string_type <A href="#m6" >str</A>(int sub = 0) const;
const_reference <A href="#m7" >operator</A>[](int n) const;
const_reference <A href="#m8">prefix</A>() const;
const_reference <A href="#m8" >prefix</A>() const;
const_reference <A href="#m9">suffix</A>() const;
const_iterator <A href="#m10">begin</A>() const;
const_iterator <A href="#m11">end</A>() const;
const_reference <A href="#m9" >suffix</A>() const;
const_iterator <A href="#m10" >begin</A>() const;
const_iterator <A href="#m11" >end</A>() const;
// format:
template &lt;class OutputIterator&gt;
OutputIterator <A href="#m12">format</A>(OutputIterator out,
OutputIterator <A href="#m12" >format</A>(OutputIterator out,
const string_type&amp; fmt,
match_flag_type flags = format_default) const;
string_type <A href="#m13">format</A>(const string_type&amp; fmt,
string_type <A href="#m13" >format</A>(const string_type&amp; fmt,
match_flag_type flags = format_default) const;
allocator_type <A href="#m14">get_allocator</A>() const;
void <A href="#m15">swap</A>(match_results&amp; that);
allocator_type <A href="#m14" >get_allocator</A>() const;
void <A href="#m15" >swap</A>(match_results&amp; that);
#ifdef BOOST_REGEX_MATCH_EXTRA
typedef typename value_type::capture_sequence_type <A href="#m16" >capture_sequence_type</A>;
const capture_sequence_type&amp; <A href="#m17" >captures</A>(std::size_t i)const;
#endif
};
template &lt;class BidirectionalIterator, class Allocator&gt;
bool <A href="#n1">operator</A> == (const match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m1,
bool <A href="#n1" >operator</A> == (const match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m1,
const match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m2);
template &lt;class BidirectionalIterator, class Allocator&gt;
bool <A href="#n2">operator</A> != (const match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m1,
bool <A href="#n2" >operator</A> != (const match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m1,
const match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m2);
template &lt;class charT, class traits, class BidirectionalIterator, class Allocator&gt;
basic_ostream&lt;charT, traits&gt;&amp;
<A href="#n3">operator</A> &lt;&lt; (basic_ostream&lt;charT, traits&gt;&amp; os,
<A href="#n3" >operator</A> &lt;&lt; (basic_ostream&lt;charT, traits&gt;&amp; os,
const match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m);
template &lt;class BidirectionalIterator, class Allocator&gt;
void <A href="#n4">swap</A>(match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m1,
void <A href="#n4" >swap</A>(match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m1,
match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m2);
</pre>
<h3><a name="description"></a>Description</h3>
@ -139,42 +143,41 @@ match_results(const Allocator&amp; a = Allocator());
of this function are indicated in the table:</p>
<p align="center"></p>
<center>
<table id="Table2" cellspacing="1" cellpadding="7" width="624" border="1">
<table id="Table2" cellSpacing="1" cellPadding="7" width="624" border="1">
<tbody>
<tr>
<td valign="top" width="50%"><b></b>
<td vAlign="top" width="50%"><b></b>
<p><b>Element</b></p>
</td>
<td valign="top" width="50%"><b></b>
<td vAlign="top" width="50%"><b></b>
<p><b>Value</b></p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>empty()</p>
</td>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>true</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>size()</p>
</td>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>0</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>str()</p>
</td>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>basic_string&lt;charT&gt;()</p>
</td>
</tr>
</tbody>
</table>
</tbody></table>
</center>
<p>&nbsp;</p>
<pre><A name=c2></A>
@ -190,82 +193,81 @@ match_results&amp; operator=(const match_results&amp; m);
indicated in the table:</p>
<p align="center"></p>
<center>
<table id="Table3" cellspacing="1" cellpadding="7" width="624" border="1">
<table id="Table3" cellSpacing="1" cellPadding="7" width="624" border="1">
<tbody>
<tr>
<td valign="top" width="50%"><b></b>
<td vAlign="top" width="50%"><b></b>
<p><b>Element</b></p>
</td>
<td valign="top" width="50%"><b></b>
<td vAlign="top" width="50%"><b></b>
<p><b>Value</b></p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>empty()</p>
</td>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>m.empty().</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>size()</p>
</td>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>m.size().</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>str(n)</p>
</td>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>m.str(n) for all integers n &lt; m.size().</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>prefix()</p>
</td>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>m.prefix().</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>suffix()</p>
</td>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>m.suffix().</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>(*this)[n]</p>
</td>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>m[n] for all integers n &lt; m.size().</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>length(n)</p>
</td>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>m.length(n) for all integers n &lt; m.size().</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>position(n)</p>
</td>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>m.position(n) for all integers n &lt; m.size().</p>
</td>
</tr>
</tbody>
</table>
</tbody></table>
</center>
<h4>match_results size</h4>
<pre><A name=m1></A>
@ -342,11 +344,10 @@ const_iterator end()const;
<p><b>Effects:</b> Returns a terminating iterator that enumerates over all the
marked sub-expression matches stored in *this.</p>
<h4><A name="format"></A>match_results reformatting</h4>
<pre><A name=m12></A>
template &lt;class OutputIterator&gt;
<pre>template &lt;class OutputIterator&gt;
OutputIterator format(OutputIterator out,
const string_type&amp; fmt,
<a href="match_flag_type.html">match_flag_type</a> flags = format_default);
<A href="match_flag_type.html" >match_flag_type</A> flags = format_default);
</pre>
<b></b>
<p><b>Requires:</b> The type OutputIterator conforms to the Output Iterator
@ -356,34 +357,34 @@ OutputIterator format(OutputIterator out,
OutputIterator <i>out</i>. For each format specifier or escape sequence in <i>fmt</i>,
replace that sequence with either the character(s) it represents, or the
sequence of characters within *this to which it refers. The bitmasks specified
in <i><a href="match_flag_type.html">flags</a></i> determines what <a href="format_syntax.html">
format specifiers or escape sequences are recognized</a>, by default this is
in <i><A href="match_flag_type.html">flags</A></i> determines what <A href="format_syntax.html">
format specifiers or escape sequences are recognized</A>, by default this is
the format used by ECMA-262, ECMAScript Language Specification, Chapter 15 part
5.4.11 String.prototype.replace.</p>
<b></b>
<p><b>Returns:</b> <i>out</i>.</p>
<pre><A name=m13></A>
string_type format(const string_type&amp; fmt,
<a href="match_flag_type.html">match_flag_type</a> flags = format_default);
<A href="match_flag_type.html" >match_flag_type</A> flags = format_default);
</pre>
<b></b>
<p><b>Effects:</b> Returns a copy of the string <i>fmt</i>. For each format
specifier or escape sequence in <i>fmt</i>, replace that sequence with either
the character(s) it represents, or the sequence of characters within *this to
which it refers. The bitmasks specified in <i><a href="match_flag_type.html">flags</a></i>
determines what <a href="format_syntax.html">format specifiers or escape sequences
are recognized</a>, by default this is the format used by ECMA-262,
which it refers. The bitmasks specified in <i><A href="match_flag_type.html">flags</A></i>
determines what <A href="format_syntax.html">format specifiers or escape sequences
are recognized</A>, by default this is the format used by ECMA-262,
ECMAScript Language Specification, Chapter 15 part 5.4.11
String.prototype.replace.</p>
<pre><A name=m14></A>
allocator_type get_allocator()const;
<H4>Allocator access</H4>
<pre>allocator_type get_allocator()const;
</pre>
<b></b>
<p><b>Effects:</b> Returns a copy of the Allocator that was passed to the object's
constructor.</p>
<pre><A name=m15></A>
void swap(match_results&amp; that);
</pre>
<H4><A name="m15"></A>Swap</H4>
<PRE>void swap(match_results&amp; that);
</PRE>
<b></b>
<p><b>Effects:</b> Swaps the contents of the two sequences.</p>
<b></b>
@ -392,6 +393,36 @@ void swap(match_results&amp; that);
sequence of matched sub-expressions that were in <code>*this</code>.</p>
<b></b>
<p><b>Complexity:</b> constant time.</p>
<H4>Captures</H4>
<PRE><A name=m16></A>typedef typename value_type::capture_sequence_type capture_sequence_type;</PRE>
<P>Defines an implementation-specific type that&nbsp;satisfies the requirements of
a standard library Sequence (21.1.1 including the optional Table 68
operations),&nbsp;whose value_type is a <EM>sub_match&lt;BidirectionalIterator&gt;</EM>.&nbsp;This
type happens to be <EM>std::vector&lt;sub_match&lt;BidirectionalIterator&gt; &gt;</EM>,
but you shouldn't actually rely on that.</P>
<PRE><A name=m17></A>const capture_sequence_type&amp; <A href="#m8" >captures</A>(std::size_t i)const; </PRE>
<P><STRONG>Effects:</STRONG> returns a sequence containing all the captures
obtained for sub-expression <EM>i</EM>.</P>
<P><STRONG>Returns:</STRONG> <code>(*this)[i].captures();</code></P>
<P><STRONG>Preconditions:</STRONG> the library must be built and used with
BOOST_REGEX_MATCH_EXTRA defined, and you must pass the flag <A href="match_flag_type.html">
match_extra</A> to the regex matching functions (<A href="regex_match.html">regex_match</A>,
<A href="regex_search.html">regex_search</A>, <A href="regex_iterator.html">regex_iterator</A>
or <A href="regex_token_iterator.html">regex_token_iterator</A>) in order for
this member function to be defined and return useful information.</P>
<P><STRONG>Rationale:</STRONG> Enabling this feature has several consequences:
</P>
<UL>
<LI>
sub_match occupies more memory resulting in complex expressions running out of
memory or stack space more quickly during matching.
<LI>
The matching algorithms are less efficient at handling some features
(independent sub-expressions for example), even when match_extra is not used.
<LI>
The matching algorithms are much less efficient (i.e. slower), when match_extra
is used.&nbsp; Mostly this is down to the extra memory allocations that have to
take place.</LI></UL>
<h4>match_results non-members</h4>
<PRE><A name=n1></A>template &lt;class BidirectionalIterator, class Allocator&gt;
bool operator == (const match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m1,
@ -418,10 +449,10 @@ void swap(match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m1,
24 Oct 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
<p><i><EFBFBD> Copyright John Maddock&nbsp;1998-
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
<P><I>Use, modification and distribution are subject to the Boost Software License,
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
</body>
</html>

View File

@ -3,21 +3,20 @@
<head>
<title>Boost.Regex: sub_match</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<LINK href="../../../boost.css" type="text/css" rel="stylesheet"></head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
<td vAlign="top" width="300">
<h3><A href="../../../index.htm"><IMG height="86" alt="C++ Boost" src="../../../c++boost.gif" width="277" border="0"></A></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">sub_match</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
<h3><A href="index.html"><IMG height="45" alt="Boost.Regex Index" src="uarrow.gif" width="43" border="0"></A></h3>
</td>
</TR>
</TABLE>
@ -41,20 +40,28 @@
<P>Objects of type <EM>sub_match</EM> may be compared to objects of type <EM>std::basic_string</EM>,
or <EM>const charT*</EM> or <EM>const charT</EM>
.
<P>Objects of type <EM>sub_match</EM> may be added to objects of type <EM>std::basic_string</EM>,
or <EM>const charT* </EM>or <EM>const charT</EM>, to produce a new <EM>std::basic_string
</EM>
object.
<P>When the marked sub-expression denoted by an object of type sub_match&lt;&gt;
participated in a regular expression match then member <CODE>matched</CODE> evaluates
to true, and members <CODE>first</CODE> and <CODE>second</CODE> denote the
range of characters <CODE>[first,second)</CODE> which formed that match.
Otherwise <CODE>matched</CODE> is false, and members <CODE>first</CODE> and <CODE>second</CODE>
contained undefined values.</P>
<P>When the marked sub-expression denoted by an object of type sub_match&lt;&gt;
was repeated, then the sub_match object represents the match obtained by the
last repeat.&nbsp; The complete set of all the captures obtained for all the
repeats, may be accessed via the captures() member function (Note: this has
serious performance implications, you have to explicitly enable this feature).</P>
<P>If an object of type <CODE>sub_match&lt;&gt;</CODE> represents sub-expression 0
- that is to say the whole match - then member <CODE>matched</CODE> is always
true, unless a partial match was obtained as a result of the flag <CODE>match_partial</CODE>
being passed to a regular expression algorithm, in which case member <CODE>matched</CODE>
is false, and members <CODE>first</CODE> and <CODE>second</CODE> represent the
character range that formed the partial match.</P>
<PRE>
namespace boost{
<PRE>namespace boost{
template &lt;class BidirectionalIterator&gt;
class sub_match : public std::pair&lt;BidirectionalIterator, BidirectionalIterator&gt;
@ -64,36 +71,40 @@ public:
typedef typename iterator_traits&lt;BidirectionalIterator&gt;::difference_type difference_type;
typedef BidirectionalIterator iterator;
bool <A href="#m1">matched</A>;
bool <A href="#m1" >matched</A>;
difference_type <A href="#m2">length</A>()const;
operator <A href="#m3">basic_string</A>&lt;value_type&gt;()const;
basic_string&lt;value_type&gt; <A href="#m4">str</A>()const;
difference_type <A href="#m2" >length</A>()const;
operator <A href="#m3" >basic_string</A>&lt;value_type&gt;()const;
basic_string&lt;value_type&gt; <A href="#m4" >str</A>()const;
int <A href="#m5">compare</A>(const sub_match&amp; s)const;
int <A href="#m6">compare</A>(const basic_string&lt;value_type&gt;&amp; s)const;
int <A href="#m7">compare</A>(const value_type* s)const;
int <A href="#m5" >compare</A>(const sub_match&amp; s)const;
int <A href="#m6" >compare</A>(const basic_string&lt;value_type&gt;&amp; s)const;
int <A href="#m7" >compare</A>(const value_type* s)const;
#ifdef BOOST_REGEX_MATCH_EXTRA
typedef implementation-private <A href="#m9">capture_sequence_type</A>;
const capture_sequence_type&amp; <A href="#m8" >captures</A>()const;
#endif
};
//
// comparisons to another sub_match:
//
template &lt;class BidirectionalIterator&gt;
bool <A href="#o11">operator</A> == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o11" >operator</A> == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o12">operator</A> != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o12" >operator</A> != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o13">operator</A> &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o13" >operator</A> &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o14">operator</A> &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o14" >operator</A> &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o15">operator</A> &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o15" >operator</A> &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o16">operator</A> &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o16" >operator</A> &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
@ -101,166 +112,165 @@ bool <A href="#o16">operator</A> &gt; (const sub_match&lt;BidirectionalIterator&
// comparisons to a basic_string:
//
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool <A href="#o21">operator</A> == (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; lhs,
bool <A href="#o21" >operator</A> == (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool <A href="#o22">operator</A> != (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; lhs,
bool <A href="#o22" >operator</A> != (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool <A href="#o23">operator</A> &lt; (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; lhs,
bool <A href="#o23" >operator</A> &lt; (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool <A href="#o24">operator</A> &gt; (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; lhs,
bool <A href="#o24" >operator</A> &gt; (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool <A href="#o25">operator</A> &gt;= (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; lhs,
bool <A href="#o25" >operator</A> &gt;= (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool <A href="#o26">operator</A> &lt;= (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; lhs,
bool <A href="#o26" >operator</A> &lt;= (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool <A href="#o31">operator</A> == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o31" >operator</A> == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool <A href="#o32">operator</A> != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o32" >operator</A> != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool <A href="#o33">operator</A> &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o33" >operator</A> &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool <A href="#o34">operator</A> &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o34" >operator</A> &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool <A href="#o35">operator</A> &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o35" >operator</A> &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool <A href="#o36">operator</A> &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o36" >operator</A> &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; rhs);
//
// comparisons to a pointer to a character array:
//
template &lt;class BidirectionalIterator&gt;
bool <A href="#o41">operator</A> == (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
bool <A href="#o41" >operator</A> == (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o42">operator</A> != (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
bool <A href="#o42" >operator</A> != (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o43">operator</A> &lt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
bool <A href="#o43" >operator</A> &lt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o44">operator</A> &gt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
bool <A href="#o44" >operator</A> &gt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o45">operator</A> &gt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
bool <A href="#o45" >operator</A> &gt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o46">operator</A> &lt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
bool <A href="#o46" >operator</A> &lt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o51">operator</A> == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o51" >operator</A> == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o52">operator</A> != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o52" >operator</A> != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o53">operator</A> &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o53" >operator</A> &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o54">operator</A> &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o54" >operator</A> &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o55">operator</A> &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o55" >operator</A> &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o56">operator</A> &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o56" >operator</A> &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs);
//
// comparisons to a single character:
//
template &lt;class BidirectionalIterator&gt;
bool <A href="#o61">operator</A> == (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
bool <A href="#o61" >operator</A> == (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o62">operator</A> != (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
bool <A href="#o62" >operator</A> != (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o63">operator</A> &lt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
bool <A href="#o63" >operator</A> &lt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o64">operator</A> &gt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
bool <A href="#o64" >operator</A> &gt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o65">operator</A> &gt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
bool <A href="#o65" >operator</A> &gt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o66">operator</A> &lt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
bool <A href="#o66" >operator</A> &lt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o71">operator</A> == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o71" >operator</A> == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o72">operator</A> != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o72" >operator</A> != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o73">operator</A> &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o73" >operator</A> &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o74">operator</A> &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o74" >operator</A> &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o75">operator</A> &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o75" >operator</A> &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o76">operator</A> &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o76" >operator</A> &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs);
//
// addition operators:
//
template &lt;class RandomAccessIterator, class traits, class Allocator&gt;
std::basic_string&lt;typename iterator_traits&lt;RandomAccessIterator&gt;::value_type, traits, Allocator&gt;
<A href="#o81">operator</A> + (const std::basic_string&lt;typename iterator_traits&lt;RandomAccessIterator&gt;::value_type, traits, Allocator&gt;&amp; s,
const sub_match&lt;RandomAccessIterator&gt;&amp; m);
template &lt;class RandomAccessIterator, class traits, class Allocator&gt;
std::basic_string&lt;typename iterator_traits&lt;RandomAccessIterator&gt;::value_type, traits, Allocator&gt;
<A href="#o82">operator</A> + (const sub_match&lt;RandomAccessIterator&gt;&amp; m,
const std::basic_string&lt;typename iterator_traits&lt;RandomAccessIterator&gt;::value_type, traits, Allocator&gt;&amp; s);
template &lt;class RandomAccessIterator&gt; std::basic_string&lt;typename iterator_traits&lt;RandomAccessIterator&gt;::value_type&gt;
<A href="#o83">operator</A> + (typename iterator_traits&lt;RandomAccessIterator&gt;::value_type const* s,
const sub_match&lt;RandomAccessIterator&gt;&amp; m);
template &lt;class RandomAccessIterator&gt; std::basic_string&lt;typename iterator_traits&lt;RandomAccessIterator&gt;::value_type&gt;
<A href="#o84">operator</A> + (const sub_match&lt;RandomAccessIterator&gt;&amp; m,
typename iterator_traits&lt;RandomAccessIterator&gt;::value_type const * s);
template &lt;class RandomAccessIterator&gt;
std::basic_string&lt;typename iterator_traits&lt;RandomAccessIterator&gt;::value_type&gt;
<A href="#o85">operator</A> + (typename iterator_traits&lt;RandomAccessIterator&gt;::value_type const&amp; s,
const sub_match&lt;RandomAccessIterator&gt;&amp; m);
template &lt;class RandomAccessIterator&gt;
std::basic_string&lt;typename iterator_traits&lt;RandomAccessIterator&gt;::value_type&gt;
<A href="#o86">operator</A> + (const sub_match&lt;RandomAccessIterator&gt;&amp; m,
typename iterator_traits&lt;RandomAccessIterator&gt;::value_type const&amp; s);
template &lt;class RandomAccessIterator&gt;
std::basic_string&lt;typename iterator_traits&lt;RandomAccessIterator&gt;::value_type&gt;
<A href="#o87">operator</A> + (const sub_match&lt;RandomAccessIterator&gt;&amp; m1,
const sub_match&lt;RandomAccessIterator&gt;&amp; m2);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
std::basic_string&lt;typename iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;
<A href="#o81" >operator</A> + (const std::basic_string&lt;typename iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; s,
const sub_match&lt;BidirectionalIterator&gt;&amp; m);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
std::basic_string&lt;typename iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;
<A href="#o82" >operator</A> + (const sub_match&lt;BidirectionalIterator&gt;&amp; m,
const std::basic_string&lt;typename iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; s);
template &lt;class BidirectionalIterator&gt; std::basic_string&lt;typename iterator_traits&lt;BidirectionalIterator&gt;::value_type&gt;
<A href="#o83" >operator</A> + (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* s,
const sub_match&lt;BidirectionalIterator&gt;&amp; m);
template &lt;class BidirectionalIterator&gt; std::basic_string&lt;typename iterator_traits&lt;BidirectionalIterator&gt;::value_type&gt;
<A href="#o84" >operator</A> + (const sub_match&lt;BidirectionalIterator&gt;&amp; m,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const * s);
template &lt;class BidirectionalIterator&gt;
std::basic_string&lt;typename iterator_traits&lt;BidirectionalIterator&gt;::value_type&gt;
<A href="#o85" >operator</A> + (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; s,
const sub_match&lt;BidirectionalIterator&gt;&amp; m);
template &lt;class BidirectionalIterator&gt;
std::basic_string&lt;typename iterator_traits&lt;BidirectionalIterator&gt;::value_type&gt;
<A href="#o86" >operator</A> + (const sub_match&lt;BidirectionalIterator&gt;&amp; m,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; s);
template &lt;class BidirectionalIterator&gt;
std::basic_string&lt;typename iterator_traits&lt;BidirectionalIterator&gt;::value_type&gt;
<A href="#o87" >operator</A> + (const sub_match&lt;BidirectionalIterator&gt;&amp; m1,
const sub_match&lt;BidirectionalIterator&gt;&amp; m2);
//
// stream inserter:
//
template &lt;class charT, class traits, class BidirectionalIterator&gt;
basic_ostream&lt;charT, traits&gt;&amp;
<A href="#oi">operator</A> &lt;&lt; (basic_ostream&lt;charT, traits&gt;&amp; os,
<A href="#oi" >operator</A> &lt;&lt; (basic_ostream&lt;charT, traits&gt;&amp; os,
const sub_match&lt;BidirectionalIterator&gt;&amp; m);
} // namespace boost</PRE>
<H3>Description</H3>
<H4>
sub_match members</H4>
<H4>sub_match members</H4>
<PRE>typedef typename std::iterator_traits&lt;iterator&gt;::value_type value_type;</PRE>
<P>The type pointed to by the iterators.</P>
<PRE>typedef typename std::iterator_traits&lt;iterator&gt;::difference_type difference_type;</PRE>
@ -274,59 +284,77 @@ basic_ostream&lt;charT, traits&gt;&amp;
<PRE><A name=m1></A>bool matched</PRE>
<P>A Boolean value denoting whether this sub-expression participated in the match.</P>
<PRE><A name=m2></A>static difference_type length();</PRE>
<P>
<B>Effects: </B>returns the length of this matched sub-expression, or 0 if this
<P><B>Effects: </B>returns the length of this matched sub-expression, or 0 if this
sub-expression was not matched: <CODE>matched ? distance(first, second) : 0)</CODE>.</P>
<PRE><A name=m3></A>operator basic_string&lt;value_type&gt;()const;</PRE>
<P>
<B>Effects: </B>converts *this into a string: returns <CODE>(matched ?
<P><B>Effects: </B>converts *this into a string: returns <CODE>(matched ?
basic_string&lt;value_type&gt;(first, second) :
basic_string&lt;value_type&gt;()).</P>
</CODE><PRE><A name=m4></A>basic_string&lt;value_type&gt; str()const;</PRE>
<P><B> Effects: </B>returns a string representation of *this:&nbsp; <CODE>(matched ?
<P><B>Effects: </B>returns a string representation of *this:&nbsp; <CODE>(matched ?
basic_string&lt;value_type&gt;(first, second) :
basic_string&lt;value_type&gt;())</CODE>.</P>
<PRE><A name=m5></A>int compare(const sub_match&amp; s)const;</PRE>
<P>
<B>Effects: </B>performs a lexical comparison to <EM>s</EM>: returns <CODE>str().compare(s.str())</CODE>.</P>
<P><B>Effects: </B>performs a lexical comparison to <EM>s</EM>: returns <CODE>str().compare(s.str())</CODE>.</P>
<PRE><A name=m6></A>int compare(const basic_string&lt;value_type&gt;&amp; s)const;</PRE>
<P><B> Effects: </B>compares *this to the string s: returns <CODE>str().compare(s)</CODE>.</P>
<P><B>Effects: </B>compares *this to the string s: returns <CODE>str().compare(s)</CODE>.</P>
<PRE><A name=m7></A>int compare(const value_type* s)const;</PRE>
<P>
<B>Effects:<B></B> </B>compares *this to the null-terminated string <EM>s</EM>:<B>&nbsp;</B>returns
<P><B>Effects:<B></B> </B>compares *this to the null-terminated string <EM>s</EM>:<B>&nbsp;</B>returns
<CODE>str().compare(s)</CODE>.</P>
<H4>
sub_match non-member operators</H4>
<PRE><A name=m9></A>typedef implementation-private capture_sequence_type;</PRE>
<P>Defines an implementation-specific type that&nbsp;satisfies the requirements of
a standard library Sequence (21.1.1 including the optional Table 68
operations),&nbsp;whose value_type is a <EM>sub_match&lt;BidirectionalIterator&gt;</EM>.&nbsp;This
type happens to be <EM>std::vector&lt;sub_match&lt;BidirectionalIterator&gt; &gt;</EM>,
but you shouldn't actually rely on that.</P>
<PRE><A name=m8></A>const capture_sequence_type&amp; <A href="#m8" >captures</A>()const; </PRE>
<P><STRONG>Effects:</STRONG> returns a sequence containing all the captures
obtained for this sub-expression.</P>
<P><STRONG>Preconditions:</STRONG> the library must be built and used with
BOOST_REGEX_MATCH_EXTRA defined, and you must pass the flag <A href="match_flag_type.html">
match_extra</A> to the regex matching functions (<A href="regex_match.html">regex_match</A>,
<A href="regex_search.html">regex_search</A>, <A href="regex_iterator.html">regex_iterator</A>
or <A href="regex_token_iterator.html">regex_token_iterator</A>) in order for
this member function to be defined and return useful information.</P>
<P><STRONG>Rationale:</STRONG> Enabling this feature has several consequences:
</P>
<UL>
<LI>
sub_match occupies more memory resulting in complex expressions running out of
memory or stack space more quickly during matching.
<LI>
The matching algorithms are less efficient at handling some features
(independent sub-expressions for example), even when match_extra is not used.
<LI>
The matching algorithms are much less efficient (i.e. slower), when match_extra
is used.&nbsp; Mostly this is down to the extra memory allocations that have to
take place.</LI></UL>
<H4>sub_match non-member operators</H4>
<H5>Comparisons against self</H5>
<PRE><A name=o11></A>template &lt;class BidirectionalIterator&gt;
bool operator == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);</PRE>
<P>
<B>Effects: </B>returns <CODE>lhs.compare(rhs) == 0</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs.compare(rhs) == 0</CODE>.</P>
<PRE><A name=o12></A>template &lt;class BidirectionalIterator&gt;
bool operator != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);</PRE>
<P>
<B>Effects: </B>returns <CODE>lhs.compare(rhs) != 0</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs.compare(rhs) != 0</CODE>.</P>
<PRE><A name=o13></A>template &lt;class BidirectionalIterator&gt;
bool operator &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);</PRE>
<P>
<B>Effects: </B>returns <CODE>lhs.compare(rhs) &lt; 0</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs.compare(rhs) &lt; 0</CODE>.</P>
<PRE><A name=o14></A>template &lt;class BidirectionalIterator&gt;
bool operator &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);</PRE>
<P><B> Effects: </B>returns <CODE>lhs.compare(rhs) &lt;= 0</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs.compare(rhs) &lt;= 0</CODE>.</P>
<PRE><A name=o15></A>template &lt;class BidirectionalIterator&gt;
bool operator &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);</PRE>
<P>
<B>Effects: </B>returns <CODE>lhs.compare(rhs) &gt;= 0</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs.compare(rhs) &gt;= 0</CODE>.</P>
<PRE><A name=o16></A>template &lt;class BidirectionalIterator&gt;
bool operator &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);</PRE>
<P>
<B>Effects: </B>returns <CODE>lhs.compare(rhs) &gt; 0</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs.compare(rhs) &gt; 0</CODE>.</P>
<H5>Comparisons with std::basic_string</H5>
<pre><A name=o21></A>
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
@ -382,159 +410,135 @@ bool operator &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
<PRE><A name=o41></A>template &lt;class BidirectionalIterator&gt;
bool operator == (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs == rhs.str()</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs == rhs.str()</CODE>.</P>
<PRE><A name=o42></A>template &lt;class BidirectionalIterator&gt;
bool operator != (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs != rhs.str()</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs != rhs.str()</CODE>.</P>
<PRE></A><A name=o43></A>template &lt;class BidirectionalIterator&gt;
bool operator &lt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs &lt; rhs.str()</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs &lt; rhs.str()</CODE>.</P>
<PRE><A name=o44></A>template &lt;class BidirectionalIterator&gt;
bool operator &gt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs &gt; rhs.str()</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs &gt; rhs.str()</CODE>.</P>
<PRE><A name=o45></A>template &lt;class BidirectionalIterator&gt;
bool operator &gt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs &gt;= rhs.str()</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs &gt;= rhs.str()</CODE>.</P>
<PRE><A name=o46></A>template &lt;class BidirectionalIterator&gt;
bool operator &lt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs &lt;= rhs.str()</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs &lt;= rhs.str()</CODE>.</P>
<PRE><A name=o51></A>template &lt;class BidirectionalIterator&gt;
bool operator == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs.str() == rhs</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs.str() == rhs</CODE>.</P>
<PRE><A name=o52></A>template &lt;class BidirectionalIterator&gt;
bool operator != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs.str() != rhs</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs.str() != rhs</CODE>.</P>
<PRE><A name=o53></A>template &lt;class BidirectionalIterator&gt;
bool operator &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs.str() &lt; rhs</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs.str() &lt; rhs</CODE>.</P>
<PRE><A name=o54></A>template &lt;class BidirectionalIterator&gt;
bool operator &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs.str() &gt; rhs</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs.str() &gt; rhs</CODE>.</P>
<PRE><A name=o55></A>template &lt;class BidirectionalIterator&gt;
bool operator &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs.str() &gt;= rhs</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs.str() &gt;= rhs</CODE>.</P>
<PRE><A name=o56></A>template &lt;class BidirectionalIterator&gt;
bool operator &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs.str() &lt;= rhs</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs.str() &lt;= rhs</CODE>.</P>
<H5>Comparisons with a single character</H5>
<PRE><A name=o61></A>template &lt;class BidirectionalIterator&gt;
bool operator == (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs == rhs.str()</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs == rhs.str()</CODE>.</P>
<PRE><A name=o62></A>template &lt;class BidirectionalIterator&gt;
bool operator != (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs != rhs.str()</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs != rhs.str()</CODE>.</P>
<PRE><A name=o63></A>template &lt;class BidirectionalIterator&gt;
bool operator &lt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs &lt; rhs.str()</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs &lt; rhs.str()</CODE>.</P>
<PRE><A name=o64></A>template &lt;class BidirectionalIterator&gt;
bool operator &gt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs &gt; rhs.str()</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs &gt; rhs.str()</CODE>.</P>
<PRE><A name=o65></A>template &lt;class BidirectionalIterator&gt;
bool operator &gt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs &gt;= rhs.str()</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs &gt;= rhs.str()</CODE>.</P>
<PRE><A name=o66></A>template &lt;class BidirectionalIterator&gt;
bool operator &lt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs &lt;= rhs.str()</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs &lt;= rhs.str()</CODE>.</P>
<PRE><A name=o71></A>template &lt;class BidirectionalIterator&gt;
bool operator == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs.str() == rhs</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs.str() == rhs</CODE>.</P>
<PRE><A name=o72></A>template &lt;class BidirectionalIterator&gt;
bool operator != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs.str() != rhs</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs.str() != rhs</CODE>.</P>
<PRE><A name=o73></A>template &lt;class BidirectionalIterator&gt;
bool operator &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs.str() &lt; rhs</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs.str() &lt; rhs</CODE>.</P>
<PRE><A name=o74></A>template &lt;class BidirectionalIterator&gt;
bool operator &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs.str() &gt; rhs</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs.str() &gt; rhs</CODE>.</P>
<PRE><A name=o75></A>template &lt;class BidirectionalIterator&gt;
bool operator &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs.str() &gt;= rhs</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs.str() &gt;= rhs</CODE>.</P>
<PRE><A name=o76></A>template &lt;class BidirectionalIterator&gt;
bool operator &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs.str() &lt;= rhs</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs.str() &lt;= rhs</CODE>.</P>
<h5>Addition operators</h5>
<P>The addition operators for sub_match allow you to add a sub_match to any type
to which you can add a std::string and obtain a new string as the result.</P>
<PRE><A name=o81></A>template &lt;class RandomAccessIterator, class traits, class Allocator&gt;
std::basic_string&lt;typename iterator_traits&lt;RandomAccessIterator&gt;::value_type, traits, Allocator&gt;
operator + (const std::basic_string&lt;typename iterator_traits&lt;RandomAccessIterator&gt;::value_type, traits, Allocator&gt;&amp; s,
const sub_match&lt;RandomAccessIterator&gt;&amp; m); </PRE>
<PRE><A name=o81></A>template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
std::basic_string&lt;typename iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;
operator + (const std::basic_string&lt;typename iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; s,
const sub_match&lt;BidirectionalIterator&gt;&amp; m); </PRE>
<P><B>Effects: </B>returns <CODE>s + m.str()</CODE>.</P>
<PRE><A name=o82></A>template &lt;class RandomAccessIterator, class traits, class Allocator&gt;
std::basic_string&lt;typename iterator_traits&lt;RandomAccessIterator&gt;::value_type, traits, Allocator&gt;
operator + (const sub_match&lt;RandomAccessIterator&gt;&amp; m,
const std::basic_string&lt;typename iterator_traits&lt;RandomAccessIterator&gt;::value_type, traits, Allocator&gt;&amp; s); </PRE>
<PRE><A name=o82></A>template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
std::basic_string&lt;typename iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;
operator + (const sub_match&lt;BidirectionalIterator&gt;&amp; m,
const std::basic_string&lt;typename iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; s); </PRE>
<P><B>Effects: </B>returns <CODE>m.str() + s</CODE>.</P>
<PRE><A name=o83></A>template &lt;class RandomAccessIterator&gt; std::basic_string&lt;typename iterator_traits&lt;RandomAccessIterator&gt;::value_type&gt;
operator + (typename iterator_traits&lt;RandomAccessIterator&gt;::value_type const* s,
const sub_match&lt;RandomAccessIterator&gt;&amp; m); </PRE>
<PRE><A name=o83></A>template &lt;class BidirectionalIterator&gt; std::basic_string&lt;typename iterator_traits&lt;BidirectionalIterator&gt;::value_type&gt;
operator + (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* s,
const sub_match&lt;BidirectionalIterator&gt;&amp; m); </PRE>
<P><B>Effects: </B>returns <CODE>s + m.str()</CODE>.</P>
<PRE><A name=o84></A>template &lt;class RandomAccessIterator&gt; std::basic_string&lt;typename iterator_traits&lt;RandomAccessIterator&gt;::value_type&gt;
operator + (const sub_match&lt;RandomAccessIterator&gt;&amp; m,
typename iterator_traits&lt;RandomAccessIterator&gt;::value_type const * s);</PRE>
<PRE><A name=o84></A>template &lt;class BidirectionalIterator&gt; std::basic_string&lt;typename iterator_traits&lt;BidirectionalIterator&gt;::value_type&gt;
operator + (const sub_match&lt;BidirectionalIterator&gt;&amp; m,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const * s);</PRE>
<P><B>Effects: </B>returns <CODE>m.str() + s</CODE>.</P>
<PRE><A name=o85></A>template &lt;class RandomAccessIterator&gt;
std::basic_string&lt;typename iterator_traits&lt;RandomAccessIterator&gt;::value_type&gt;
operator + (typename iterator_traits&lt;RandomAccessIterator&gt;::value_type const&amp; s,
const sub_match&lt;RandomAccessIterator&gt;&amp; m); </PRE>
<PRE><A name=o85></A>template &lt;class BidirectionalIterator&gt;
std::basic_string&lt;typename iterator_traits&lt;BidirectionalIterator&gt;::value_type&gt;
operator + (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; s,
const sub_match&lt;BidirectionalIterator&gt;&amp; m); </PRE>
<P><B>Effects: </B>returns <CODE>s + m.str()</CODE>.</P>
<PRE><A name=o86></A>template &lt;class RandomAccessIterator&gt;
std::basic_string&lt;typename iterator_traits&lt;RandomAccessIterator&gt;::value_type&gt;
operator + (const sub_match&lt;RandomAccessIterator&gt;&amp; m,
typename iterator_traits&lt;RandomAccessIterator&gt;::value_type const&amp; s); </PRE>
<PRE><A name=o86></A>template &lt;class BidirectionalIterator&gt;
std::basic_string&lt;typename iterator_traits&lt;BidirectionalIterator&gt;::value_type&gt;
operator + (const sub_match&lt;BidirectionalIterator&gt;&amp; m,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; s); </PRE>
<P><B>Effects: </B>returns <CODE>m.str() + s</CODE>.</P>
<PRE><A name=o87></A>template &lt;class RandomAccessIterator&gt;
std::basic_string&lt;typename iterator_traits&lt;RandomAccessIterator&gt;::value_type&gt;
operator + (const sub_match&lt;RandomAccessIterator&gt;&amp; m1,
const sub_match&lt;RandomAccessIterator&gt;&amp; m2);</PRE>
<PRE><A name=o87></A>template &lt;class BidirectionalIterator&gt;
std::basic_string&lt;typename iterator_traits&lt;BidirectionalIterator&gt;::value_type&gt;
operator + (const sub_match&lt;BidirectionalIterator&gt;&amp; m1,
const sub_match&lt;BidirectionalIterator&gt;&amp; m2);</PRE>
<P><B>Effects: </B>returns&nbsp;<CODE>m1.str() + m2.str()</CODE>.</P>
<h5>Stream inserter</h5>
<PRE><A name=oi></A>template &lt;class charT, class traits, class BidirectionalIterator&gt;
@ -549,10 +553,10 @@ basic_ostream&lt;charT, traits&gt;&amp;
24 Oct 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
<p><i><EFBFBD> Copyright John Maddock&nbsp;1998-
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
<P><I>Use, modification and distribution are subject to the Boost Software License,
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
</body>
</html>

250
doc/captures.html Normal file
View File

@ -0,0 +1,250 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Index</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">Understanding Captures</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<H2>Marked sub-expressions</H2>
<P>Every time a Perl regular expression contains a parenthesis group (), it spits
out an extra field, known as a marked sub-expression, for example the
expression:</P>
<PRE>(\w+)\W+(\w+)</PRE>
<P>
Has two marked sub-expressions (known as $1 and $2 respectively), in addition
the complete match is known as $&amp;, everything before the first match as $`,
and everything after the match as $'.&nbsp; So if the above expression is
searched for within "@abc def--", then we obtain:</P>
<BLOCKQUOTE dir="ltr" style="MARGIN-RIGHT: 0px">
<P>
<TABLE id="Table2" cellSpacing="1" cellPadding="1" width="300" border="0">
<TR>
<TD>
<P dir="ltr" style="MARGIN-RIGHT: 0px">$`</P>
</TD>
<TD>"@"</TD>
</TR>
<TR>
<TD>$&amp;</TD>
<TD>"abc def"</TD>
</TR>
<TR>
<TD>$1</TD>
<TD>"abc"</TD>
</TR>
<TR>
<TD>$2</TD>
<TD>"def"</TD>
</TR>
<TR>
<TD>$'</TD>
<TD>"--"</TD>
</TR>
</TABLE>
</P>
</BLOCKQUOTE>
<P>In Boost.regex all these are accessible via the <A href="match_results.html">match_results</A>
class that gets filled in when calling one of the matching algorithms (<A href="regex_search.html">regex_search</A>,
<A href="regex_match.html">regex_match</A>, or <A href="regex_iterator.html">regex_iterator</A>).&nbsp;
So given:</P>
<PRE>boost::match_results&lt;IteratorType&gt; m;</PRE>
<P>The Perl and Boost.Regex equivalents are as follows:</P>
<BLOCKQUOTE dir="ltr" style="MARGIN-RIGHT: 0px">
<P>
<TABLE id="Table3" cellSpacing="1" cellPadding="1" width="300" border="0">
<TR>
<TD><STRONG>Perl</STRONG></TD>
<TD><STRONG>Boost.Regex</STRONG></TD>
</TR>
<TR>
<TD>$`</TD>
<TD>m.prefix()</TD>
</TR>
<TR>
<TD>$&amp;</TD>
<TD>m[0]</TD>
</TR>
<TR>
<TD>$n</TD>
<TD>m[n]</TD>
</TR>
<TR>
<TD>$'</TD>
<TD>m.suffix()</TD>
</TR>
</TABLE>
</P>
</BLOCKQUOTE>
<P>
<P>In Boost.Regex each sub-expression match is represented by a <A href="sub_match.html">
sub_match</A> object, this is basically just a pair of iterators denoting
the start and end possition of the sub-expression match, but there are some
additional operators provided so that objects of type sub_match behave a lot
like a std::basic_string: for example they are implicitly <A href="sub_match.html#m3">
convertible to a basic_string</A>, they can be <A href="sub_match.html#o21">compared
to a string</A>, <A href="sub_match.html#o81">added to a string</A>, or <A href="sub_match.html#oi">
streamed out to an output stream</A>.</P>
<H2>Unmatched Sub-Expressions</H2>
<P>When a regular expression match is found there is no need for all of the marked
sub-expressions to have participated in the match, for example the expression:</P>
<P>(abc)|(def)</P>
<P>can match either $1 or $2, but never both at the same time.&nbsp; In
Boost.Regex you can determine which sub-expressions matched by accessing the <A href="sub_match.html#m1">
sub_match::matched</A> data member.</P>
<H2>Repeated Captures</H2>
<P>When a marked sub-expression is repeated, then the sub-expression gets
"captured" multiple times, however normally only the final capture is
available, for example if</P>
<PRE>(?:(\w+)\W+)+</PRE>
<P>is matched against</P>
<PRE>one fine day</PRE>
<P>Then $1 will contain the string "day", and all the previous captures will have
been forgotten.</P>
<P>However, Boost.Regex has an experimental feature that allows all the capture
information to be retained - this is accessed either via the <A href="match_results.html#m17">
match_results::captures</A> member function or the <A href="sub_match.html#m8">sub_match::captures</A>
member function.&nbsp; These functions return a container that contains a
sequence of all the captures obtained during the regular expression
matching.&nbsp; The following example program shows how this information may be
used:</P>
<PRE>#include &lt;boost/regex.hpp&gt;
#include &lt;iostream&gt;
void print_captures(const std::string&amp; regx, const std::string&amp; text)
{
boost::regex e(regx);
boost::smatch what;
std::cout &lt;&lt; "Expression: \"" &lt;&lt; regx &lt;&lt; "\"\n";
std::cout &lt;&lt; "Text: \"" &lt;&lt; text &lt;&lt; "\"\n";
if(boost::regex_match(text, what, e, boost::match_extra))
{
unsigned i, j;
std::cout &lt;&lt; "** Match found **\n Sub-Expressions:\n";
for(i = 0; i &lt; what.size(); ++i)
std::cout &lt;&lt; " $" &lt;&lt; i &lt;&lt; " = \"" &lt;&lt; what[i] &lt;&lt; "\"\n";
std::cout &lt;&lt; " Captures:\n";
for(i = 0; i &lt; what.size(); ++i)
{
std::cout &lt;&lt; " $" &lt;&lt; i &lt;&lt; " = {";
for(j = 0; j &lt; what.captures(i).size(); ++j)
{
if(j)
std::cout &lt;&lt; ", ";
else
std::cout &lt;&lt; " ";
std::cout &lt;&lt; "\"" &lt;&lt; what.captures(i)[j] &lt;&lt; "\"";
}
std::cout &lt;&lt; " }\n";
}
}
else
{
std::cout &lt;&lt; "** No Match found **\n";
}
}
int main(int , char* [])
{
print_captures("(([[:lower:]]+)|([[:upper:]]+))+", "aBBcccDDDDDeeeeeeee");
print_captures("(.*)bar|(.*)bah", "abcbar");
print_captures("(.*)bar|(.*)bah", "abcbah");
print_captures("^(?:(\\w+)|(?&gt;\\W+))*$", "now is the time for all good men to come to the aid of the party");
return 0;
}</PRE>
<P>Which produces the following output:</P>
<PRE>Expression: "(([[:lower:]]+)|([[:upper:]]+))+"
Text: "aBBcccDDDDDeeeeeeee"
** Match found **
Sub-Expressions:
$0 = "aBBcccDDDDDeeeeeeee"
$1 = "eeeeeeee"
$2 = "eeeeeeee"
$3 = "DDDDD"
Captures:
$0 = { "aBBcccDDDDDeeeeeeee" }
$1 = { "a", "BB", "ccc", "DDDDD", "eeeeeeee" }
$2 = { "a", "ccc", "eeeeeeee" }
$3 = { "BB", "DDDDD" }
Expression: "(.*)bar|(.*)bah"
Text: "abcbar"
** Match found **
Sub-Expressions:
$0 = "abcbar"
$1 = "abc"
$2 = ""
Captures:
$0 = { "abcbar" }
$1 = { "abc" }
$2 = { }
Expression: "(.*)bar|(.*)bah"
Text: "abcbah"
** Match found **
Sub-Expressions:
$0 = "abcbah"
$1 = ""
$2 = "abc"
Captures:
$0 = { "abcbah" }
$1 = { }
$2 = { "abc" }
Expression: "^(?:(\w+)|(?&gt;\W+))*$"
Text: "now is the time for all good men to come to the aid of the party"
** Match found **
Sub-Expressions:
$0 = "now is the time for all good men to come to the aid of the party"
$1 = "party"
Captures:
$0 = { "now is the time for all good men to come to the aid of the party" }
$1 = { "now", "is", "the", "time", "for", "all", "good", "men", "to", "come", "to", "the", "aid", "of", "the", "party" }
</PRE>
<P>Unfortunately enabling this feature has an impact on performance (even if you
don't use it), and a much bigger impact if you do use it, therefore to use this
feature you need to:</P>
<UL>
<LI>
Define BOOST_REGEX_MATCH_EXTRA for all translation units including the library
source (the best way to do this is to uncomment this define in <A href="../../../boost/regex/user.hpp">
boost/regex/user.hpp</A>
and then rebuild everything.
<LI>
Pass the <A href="match_flag_type.html">match_extra flag</A> to the particular
algorithms where you actually need the captures information (<A href="regex_search.html">regex_search</A>,
<A href="regex_match.html">regex_match</A>, or <A href="regex_iterator.html">regex_iterator</A>).
</LI>
</UL>
<P>
<HR>
<P></P>
<P></P>
<p>Revised&nbsp;
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
12&nbsp;Dec 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
<p><i><EFBFBD> Copyright John Maddock&nbsp;
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
<P><I>Use, modification and distribution are subject to the Boost Software License,
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
</body>
</html>

View File

@ -73,6 +73,7 @@
<dt><a href="partial_matches.html">Partial matches</a></dt>
<dt><a href="syntax.html">Regular Expression Syntax</a></dt>
<dt><a href="format_syntax.html">Format String Syntax</a></dt>
<dt><a href="captures.html">Understanding Captures</a></dt>
</dl>
</dd>
<dt>Deprecated interfaces</dt>

View File

@ -46,6 +46,7 @@ static const match_flag_type match_any;
static const match_flag_type match_not_null;
static const match_flag_type match_continuous;
static const match_flag_type match_partial;
static const match_flag_type match_single_line;
static const match_flag_type match_prev_avail;
static const match_flag_type match_not_dot_newline;
static const match_flag_type match_not_dot_null;
@ -167,6 +168,20 @@ static const match_flag_type format_all;
in a full match.</p>
</td>
</tr>
<TR>
<TD vAlign="top" width="50%">match_extra</TD>
<TD vAlign="top" width="50%">Instructs the matching engine to retain all available <A href="captures.html">
capture</A> information; if a capturing group is repeated then information
about every repeat is available via <A href="match_results.html#m17">match_results::captures()</A>
or <A href="sub_match.html#m8">sub_match_captures().</A></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">match_single_line</TD>
<TD vAlign="top" width="50%">Equivalent to Perl's s/ modifier; prevents ^ from
matching after an embedded newline character (so that it only matches at the
start of the text being matched), and $ from matching before an embedded
newline (so that it only matches at the end of the text being matched).</TD>
</TR>
<tr>
<td valign="top" width="50%">
<p>match_prev_avail</p>
@ -259,8 +274,7 @@ static const match_flag_type format_all;
24 Oct 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
<p><i><EFBFBD> Copyright John Maddock&nbsp;1998-
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
<P><I>Use, modification and distribution are subject to the Boost Software License,
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>

View File

@ -2,23 +2,22 @@
<html>
<head>
<title>Boost.Regex: class match_results</title>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta content="HTML Tidy, see www.w3.org" name="generator">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<LINK href="../../../boost.css" type="text/css" rel="stylesheet"></head>
<body>
<p></p>
<table id="Table1" cellspacing="1" cellpadding="1" width="100%" border="0">
<table id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<tr>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
<td vAlign="top" width="300">
<h3><A href="../../../index.htm"><IMG height="86" alt="C++ Boost" src="../../../c++boost.gif" width="277" border="0"></A></h3>
</td>
<td width="353">
<h1 align="center">Boost.Regex</h1>
<h2 align="center">class match_results</h2>
</td>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
<h3><A href="index.html"><IMG height="45" alt="Boost.Regex Index" src="uarrow.gif" width="43" border="0"></A></h3>
</td>
</tr>
</table>
@ -27,23 +26,23 @@
<hr>
<h3>Contents</h3>
<dl class="index">
<dt><a href="#synopsis">Synopsis</a> <dt><a href="#description">Description</a></dt>
<dt><A href="#synopsis">Synopsis</A> <dt><A href="#description">Description</A> </dt>
</dl>
<h3><a name="synopsis"></a>Synopsis</h3>
<p>#include &lt;<a href="../../../boost/regex.hpp">boost/regex.hpp</a>&gt;</p>
<p>#include &lt;<A href="../../../boost/regex.hpp">boost/regex.hpp</A>&gt;</p>
<p>Regular expressions are different from many simple pattern-matching algorithms
in that as well as finding an overall match they can also produce
sub-expression matches: each sub-expression being delimited in the pattern by a
pair of parenthesis (...). There has to be some method for reporting
sub-expression matches back to the user: this is achieved this by defining a
class <i>match_results</i> that acts as an indexed collection of sub-expression
matches, each sub-expression match being contained in an object of type <i><a href="sub_match.html">
sub_match</a></i> .</p>
matches, each sub-expression match being contained in an object of type <i><A href="sub_match.html">
sub_match</A></i> .</p>
<p>Template class match_results denotes a collection of character sequences
representing the result of a regular expression match. Objects of type
match_results are passed to the algorithms <a href="regex_match.html">regex_match</a>
and <a href="regex_search.html">regex_search</a>, and are returned by the
iterator <a href="regex_iterator.html">regex_iterator</a> .&nbsp; Storage for
match_results are passed to the algorithms <A href="regex_match.html">regex_match</A>
and <A href="regex_search.html">regex_search</A>, and are returned by the
iterator <A href="regex_iterator.html">regex_iterator</A> .&nbsp; Storage for
the collection is allocated and freed as necessary by the member functions of
class match_results.</p>
<p>The template class match_results conforms to the requirements of a Sequence, as
@ -51,8 +50,7 @@
const-qualified Sequences are supported.</p>
<p>Class template match_results is most commonly used as one of the typedefs
cmatch, wcmatch, smatch, or wsmatch:</p>
<pre>
template &lt;class BidirectionalIterator,
<pre>template &lt;class BidirectionalIterator,
class Allocator = allocator&lt;sub_match&lt;BidirectionalIterator&gt; &gt;
class match_results;
@ -78,52 +76,58 @@ public:
typedef basic_string&lt;char_type&gt; string_type;
// construct/copy/destroy:
explicit <A href="#c1">match_results</A>(const Allocator&amp; a = Allocator());
<A href="#c2">match_results</A>(const match_results&amp; m);
<A href="#c3">match_results</A>&amp; <A href="#c3">operator</A>=(const match_results&amp; m);
explicit <A href="#c1" >match_results</A>(const Allocator&amp; a = Allocator());
<A href="#c2" >match_results</A>(const match_results&amp; m);
<A href="#c3" >match_results</A>&amp; <A href="#c3" >operator</A>=(const match_results&amp; m);
~match_results();
// size:
size_type <A href="#m1">size</A>() const;
size_type <A href="#m2">max_size</A>() const;
bool <A href="#m3">empty</A>() const;
size_type <A href="#m1" >size</A>() const;
size_type <A href="#m2" >max_size</A>() const;
bool <A href="#m3" >empty</A>() const;
// element access:
difference_type <A href="#m4">length</A>(int sub = 0) const;
difference_type <A href="#m5">position</A>(unsigned int sub = 0) const;
string_type <A href="#m6">str</A>(int sub = 0) const;
const_reference <A href="#m7">operator</A>[](int n) const;
difference_type <A href="#m4" >length</A>(int sub = 0) const;
difference_type <A href="#m5" >position</A>(unsigned int sub = 0) const;
string_type <A href="#m6" >str</A>(int sub = 0) const;
const_reference <A href="#m7" >operator</A>[](int n) const;
const_reference <A href="#m8">prefix</A>() const;
const_reference <A href="#m8" >prefix</A>() const;
const_reference <A href="#m9">suffix</A>() const;
const_iterator <A href="#m10">begin</A>() const;
const_iterator <A href="#m11">end</A>() const;
const_reference <A href="#m9" >suffix</A>() const;
const_iterator <A href="#m10" >begin</A>() const;
const_iterator <A href="#m11" >end</A>() const;
// format:
template &lt;class OutputIterator&gt;
OutputIterator <A href="#m12">format</A>(OutputIterator out,
OutputIterator <A href="#m12" >format</A>(OutputIterator out,
const string_type&amp; fmt,
match_flag_type flags = format_default) const;
string_type <A href="#m13">format</A>(const string_type&amp; fmt,
string_type <A href="#m13" >format</A>(const string_type&amp; fmt,
match_flag_type flags = format_default) const;
allocator_type <A href="#m14">get_allocator</A>() const;
void <A href="#m15">swap</A>(match_results&amp; that);
allocator_type <A href="#m14" >get_allocator</A>() const;
void <A href="#m15" >swap</A>(match_results&amp; that);
#ifdef BOOST_REGEX_MATCH_EXTRA
typedef typename value_type::capture_sequence_type <A href="#m16" >capture_sequence_type</A>;
const capture_sequence_type&amp; <A href="#m17" >captures</A>(std::size_t i)const;
#endif
};
template &lt;class BidirectionalIterator, class Allocator&gt;
bool <A href="#n1">operator</A> == (const match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m1,
bool <A href="#n1" >operator</A> == (const match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m1,
const match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m2);
template &lt;class BidirectionalIterator, class Allocator&gt;
bool <A href="#n2">operator</A> != (const match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m1,
bool <A href="#n2" >operator</A> != (const match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m1,
const match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m2);
template &lt;class charT, class traits, class BidirectionalIterator, class Allocator&gt;
basic_ostream&lt;charT, traits&gt;&amp;
<A href="#n3">operator</A> &lt;&lt; (basic_ostream&lt;charT, traits&gt;&amp; os,
<A href="#n3" >operator</A> &lt;&lt; (basic_ostream&lt;charT, traits&gt;&amp; os,
const match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m);
template &lt;class BidirectionalIterator, class Allocator&gt;
void <A href="#n4">swap</A>(match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m1,
void <A href="#n4" >swap</A>(match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m1,
match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m2);
</pre>
<h3><a name="description"></a>Description</h3>
@ -139,42 +143,41 @@ match_results(const Allocator&amp; a = Allocator());
of this function are indicated in the table:</p>
<p align="center"></p>
<center>
<table id="Table2" cellspacing="1" cellpadding="7" width="624" border="1">
<table id="Table2" cellSpacing="1" cellPadding="7" width="624" border="1">
<tbody>
<tr>
<td valign="top" width="50%"><b></b>
<td vAlign="top" width="50%"><b></b>
<p><b>Element</b></p>
</td>
<td valign="top" width="50%"><b></b>
<td vAlign="top" width="50%"><b></b>
<p><b>Value</b></p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>empty()</p>
</td>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>true</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>size()</p>
</td>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>0</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>str()</p>
</td>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>basic_string&lt;charT&gt;()</p>
</td>
</tr>
</tbody>
</table>
</tbody></table>
</center>
<p>&nbsp;</p>
<pre><A name=c2></A>
@ -190,82 +193,81 @@ match_results&amp; operator=(const match_results&amp; m);
indicated in the table:</p>
<p align="center"></p>
<center>
<table id="Table3" cellspacing="1" cellpadding="7" width="624" border="1">
<table id="Table3" cellSpacing="1" cellPadding="7" width="624" border="1">
<tbody>
<tr>
<td valign="top" width="50%"><b></b>
<td vAlign="top" width="50%"><b></b>
<p><b>Element</b></p>
</td>
<td valign="top" width="50%"><b></b>
<td vAlign="top" width="50%"><b></b>
<p><b>Value</b></p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>empty()</p>
</td>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>m.empty().</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>size()</p>
</td>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>m.size().</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>str(n)</p>
</td>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>m.str(n) for all integers n &lt; m.size().</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>prefix()</p>
</td>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>m.prefix().</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>suffix()</p>
</td>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>m.suffix().</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>(*this)[n]</p>
</td>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>m[n] for all integers n &lt; m.size().</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>length(n)</p>
</td>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>m.length(n) for all integers n &lt; m.size().</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>position(n)</p>
</td>
<td valign="top" width="50%">
<td vAlign="top" width="50%">
<p>m.position(n) for all integers n &lt; m.size().</p>
</td>
</tr>
</tbody>
</table>
</tbody></table>
</center>
<h4>match_results size</h4>
<pre><A name=m1></A>
@ -342,11 +344,10 @@ const_iterator end()const;
<p><b>Effects:</b> Returns a terminating iterator that enumerates over all the
marked sub-expression matches stored in *this.</p>
<h4><A name="format"></A>match_results reformatting</h4>
<pre><A name=m12></A>
template &lt;class OutputIterator&gt;
<pre>template &lt;class OutputIterator&gt;
OutputIterator format(OutputIterator out,
const string_type&amp; fmt,
<a href="match_flag_type.html">match_flag_type</a> flags = format_default);
<A href="match_flag_type.html" >match_flag_type</A> flags = format_default);
</pre>
<b></b>
<p><b>Requires:</b> The type OutputIterator conforms to the Output Iterator
@ -356,34 +357,34 @@ OutputIterator format(OutputIterator out,
OutputIterator <i>out</i>. For each format specifier or escape sequence in <i>fmt</i>,
replace that sequence with either the character(s) it represents, or the
sequence of characters within *this to which it refers. The bitmasks specified
in <i><a href="match_flag_type.html">flags</a></i> determines what <a href="format_syntax.html">
format specifiers or escape sequences are recognized</a>, by default this is
in <i><A href="match_flag_type.html">flags</A></i> determines what <A href="format_syntax.html">
format specifiers or escape sequences are recognized</A>, by default this is
the format used by ECMA-262, ECMAScript Language Specification, Chapter 15 part
5.4.11 String.prototype.replace.</p>
<b></b>
<p><b>Returns:</b> <i>out</i>.</p>
<pre><A name=m13></A>
string_type format(const string_type&amp; fmt,
<a href="match_flag_type.html">match_flag_type</a> flags = format_default);
<A href="match_flag_type.html" >match_flag_type</A> flags = format_default);
</pre>
<b></b>
<p><b>Effects:</b> Returns a copy of the string <i>fmt</i>. For each format
specifier or escape sequence in <i>fmt</i>, replace that sequence with either
the character(s) it represents, or the sequence of characters within *this to
which it refers. The bitmasks specified in <i><a href="match_flag_type.html">flags</a></i>
determines what <a href="format_syntax.html">format specifiers or escape sequences
are recognized</a>, by default this is the format used by ECMA-262,
which it refers. The bitmasks specified in <i><A href="match_flag_type.html">flags</A></i>
determines what <A href="format_syntax.html">format specifiers or escape sequences
are recognized</A>, by default this is the format used by ECMA-262,
ECMAScript Language Specification, Chapter 15 part 5.4.11
String.prototype.replace.</p>
<pre><A name=m14></A>
allocator_type get_allocator()const;
<H4>Allocator access</H4>
<pre>allocator_type get_allocator()const;
</pre>
<b></b>
<p><b>Effects:</b> Returns a copy of the Allocator that was passed to the object's
constructor.</p>
<pre><A name=m15></A>
void swap(match_results&amp; that);
</pre>
<H4><A name="m15"></A>Swap</H4>
<PRE>void swap(match_results&amp; that);
</PRE>
<b></b>
<p><b>Effects:</b> Swaps the contents of the two sequences.</p>
<b></b>
@ -392,6 +393,36 @@ void swap(match_results&amp; that);
sequence of matched sub-expressions that were in <code>*this</code>.</p>
<b></b>
<p><b>Complexity:</b> constant time.</p>
<H4>Captures</H4>
<PRE><A name=m16></A>typedef typename value_type::capture_sequence_type capture_sequence_type;</PRE>
<P>Defines an implementation-specific type that&nbsp;satisfies the requirements of
a standard library Sequence (21.1.1 including the optional Table 68
operations),&nbsp;whose value_type is a <EM>sub_match&lt;BidirectionalIterator&gt;</EM>.&nbsp;This
type happens to be <EM>std::vector&lt;sub_match&lt;BidirectionalIterator&gt; &gt;</EM>,
but you shouldn't actually rely on that.</P>
<PRE><A name=m17></A>const capture_sequence_type&amp; <A href="#m8" >captures</A>(std::size_t i)const; </PRE>
<P><STRONG>Effects:</STRONG> returns a sequence containing all the captures
obtained for sub-expression <EM>i</EM>.</P>
<P><STRONG>Returns:</STRONG> <code>(*this)[i].captures();</code></P>
<P><STRONG>Preconditions:</STRONG> the library must be built and used with
BOOST_REGEX_MATCH_EXTRA defined, and you must pass the flag <A href="match_flag_type.html">
match_extra</A> to the regex matching functions (<A href="regex_match.html">regex_match</A>,
<A href="regex_search.html">regex_search</A>, <A href="regex_iterator.html">regex_iterator</A>
or <A href="regex_token_iterator.html">regex_token_iterator</A>) in order for
this member function to be defined and return useful information.</P>
<P><STRONG>Rationale:</STRONG> Enabling this feature has several consequences:
</P>
<UL>
<LI>
sub_match occupies more memory resulting in complex expressions running out of
memory or stack space more quickly during matching.
<LI>
The matching algorithms are less efficient at handling some features
(independent sub-expressions for example), even when match_extra is not used.
<LI>
The matching algorithms are much less efficient (i.e. slower), when match_extra
is used.&nbsp; Mostly this is down to the extra memory allocations that have to
take place.</LI></UL>
<h4>match_results non-members</h4>
<PRE><A name=n1></A>template &lt;class BidirectionalIterator, class Allocator&gt;
bool operator == (const match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m1,
@ -418,10 +449,10 @@ void swap(match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m1,
24 Oct 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
<p><i><EFBFBD> Copyright John Maddock&nbsp;1998-
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
<P><I>Use, modification and distribution are subject to the Boost Software License,
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
</body>
</html>

View File

@ -3,21 +3,20 @@
<head>
<title>Boost.Regex: sub_match</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<LINK href="../../../boost.css" type="text/css" rel="stylesheet"></head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
<td vAlign="top" width="300">
<h3><A href="../../../index.htm"><IMG height="86" alt="C++ Boost" src="../../../c++boost.gif" width="277" border="0"></A></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">sub_match</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
<h3><A href="index.html"><IMG height="45" alt="Boost.Regex Index" src="uarrow.gif" width="43" border="0"></A></h3>
</td>
</TR>
</TABLE>
@ -41,20 +40,28 @@
<P>Objects of type <EM>sub_match</EM> may be compared to objects of type <EM>std::basic_string</EM>,
or <EM>const charT*</EM> or <EM>const charT</EM>
.
<P>Objects of type <EM>sub_match</EM> may be added to objects of type <EM>std::basic_string</EM>,
or <EM>const charT* </EM>or <EM>const charT</EM>, to produce a new <EM>std::basic_string
</EM>
object.
<P>When the marked sub-expression denoted by an object of type sub_match&lt;&gt;
participated in a regular expression match then member <CODE>matched</CODE> evaluates
to true, and members <CODE>first</CODE> and <CODE>second</CODE> denote the
range of characters <CODE>[first,second)</CODE> which formed that match.
Otherwise <CODE>matched</CODE> is false, and members <CODE>first</CODE> and <CODE>second</CODE>
contained undefined values.</P>
<P>When the marked sub-expression denoted by an object of type sub_match&lt;&gt;
was repeated, then the sub_match object represents the match obtained by the
last repeat.&nbsp; The complete set of all the captures obtained for all the
repeats, may be accessed via the captures() member function (Note: this has
serious performance implications, you have to explicitly enable this feature).</P>
<P>If an object of type <CODE>sub_match&lt;&gt;</CODE> represents sub-expression 0
- that is to say the whole match - then member <CODE>matched</CODE> is always
true, unless a partial match was obtained as a result of the flag <CODE>match_partial</CODE>
being passed to a regular expression algorithm, in which case member <CODE>matched</CODE>
is false, and members <CODE>first</CODE> and <CODE>second</CODE> represent the
character range that formed the partial match.</P>
<PRE>
namespace boost{
<PRE>namespace boost{
template &lt;class BidirectionalIterator&gt;
class sub_match : public std::pair&lt;BidirectionalIterator, BidirectionalIterator&gt;
@ -64,36 +71,40 @@ public:
typedef typename iterator_traits&lt;BidirectionalIterator&gt;::difference_type difference_type;
typedef BidirectionalIterator iterator;
bool <A href="#m1">matched</A>;
bool <A href="#m1" >matched</A>;
difference_type <A href="#m2">length</A>()const;
operator <A href="#m3">basic_string</A>&lt;value_type&gt;()const;
basic_string&lt;value_type&gt; <A href="#m4">str</A>()const;
difference_type <A href="#m2" >length</A>()const;
operator <A href="#m3" >basic_string</A>&lt;value_type&gt;()const;
basic_string&lt;value_type&gt; <A href="#m4" >str</A>()const;
int <A href="#m5">compare</A>(const sub_match&amp; s)const;
int <A href="#m6">compare</A>(const basic_string&lt;value_type&gt;&amp; s)const;
int <A href="#m7">compare</A>(const value_type* s)const;
int <A href="#m5" >compare</A>(const sub_match&amp; s)const;
int <A href="#m6" >compare</A>(const basic_string&lt;value_type&gt;&amp; s)const;
int <A href="#m7" >compare</A>(const value_type* s)const;
#ifdef BOOST_REGEX_MATCH_EXTRA
typedef implementation-private <A href="#m9">capture_sequence_type</A>;
const capture_sequence_type&amp; <A href="#m8" >captures</A>()const;
#endif
};
//
// comparisons to another sub_match:
//
template &lt;class BidirectionalIterator&gt;
bool <A href="#o11">operator</A> == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o11" >operator</A> == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o12">operator</A> != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o12" >operator</A> != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o13">operator</A> &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o13" >operator</A> &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o14">operator</A> &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o14" >operator</A> &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o15">operator</A> &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o15" >operator</A> &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o16">operator</A> &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o16" >operator</A> &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
@ -101,166 +112,165 @@ bool <A href="#o16">operator</A> &gt; (const sub_match&lt;BidirectionalIterator&
// comparisons to a basic_string:
//
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool <A href="#o21">operator</A> == (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; lhs,
bool <A href="#o21" >operator</A> == (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool <A href="#o22">operator</A> != (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; lhs,
bool <A href="#o22" >operator</A> != (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool <A href="#o23">operator</A> &lt; (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; lhs,
bool <A href="#o23" >operator</A> &lt; (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool <A href="#o24">operator</A> &gt; (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; lhs,
bool <A href="#o24" >operator</A> &gt; (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool <A href="#o25">operator</A> &gt;= (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; lhs,
bool <A href="#o25" >operator</A> &gt;= (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool <A href="#o26">operator</A> &lt;= (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; lhs,
bool <A href="#o26" >operator</A> &lt;= (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool <A href="#o31">operator</A> == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o31" >operator</A> == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool <A href="#o32">operator</A> != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o32" >operator</A> != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool <A href="#o33">operator</A> &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o33" >operator</A> &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool <A href="#o34">operator</A> &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o34" >operator</A> &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool <A href="#o35">operator</A> &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o35" >operator</A> &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool <A href="#o36">operator</A> &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o36" >operator</A> &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; rhs);
//
// comparisons to a pointer to a character array:
//
template &lt;class BidirectionalIterator&gt;
bool <A href="#o41">operator</A> == (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
bool <A href="#o41" >operator</A> == (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o42">operator</A> != (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
bool <A href="#o42" >operator</A> != (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o43">operator</A> &lt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
bool <A href="#o43" >operator</A> &lt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o44">operator</A> &gt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
bool <A href="#o44" >operator</A> &gt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o45">operator</A> &gt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
bool <A href="#o45" >operator</A> &gt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o46">operator</A> &lt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
bool <A href="#o46" >operator</A> &lt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o51">operator</A> == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o51" >operator</A> == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o52">operator</A> != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o52" >operator</A> != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o53">operator</A> &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o53" >operator</A> &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o54">operator</A> &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o54" >operator</A> &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o55">operator</A> &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o55" >operator</A> &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o56">operator</A> &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o56" >operator</A> &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs);
//
// comparisons to a single character:
//
template &lt;class BidirectionalIterator&gt;
bool <A href="#o61">operator</A> == (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
bool <A href="#o61" >operator</A> == (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o62">operator</A> != (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
bool <A href="#o62" >operator</A> != (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o63">operator</A> &lt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
bool <A href="#o63" >operator</A> &lt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o64">operator</A> &gt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
bool <A href="#o64" >operator</A> &gt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o65">operator</A> &gt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
bool <A href="#o65" >operator</A> &gt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o66">operator</A> &lt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
bool <A href="#o66" >operator</A> &lt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o71">operator</A> == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o71" >operator</A> == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o72">operator</A> != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o72" >operator</A> != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o73">operator</A> &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o73" >operator</A> &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o74">operator</A> &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o74" >operator</A> &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o75">operator</A> &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o75" >operator</A> &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool <A href="#o76">operator</A> &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
bool <A href="#o76" >operator</A> &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs);
//
// addition operators:
//
template &lt;class RandomAccessIterator, class traits, class Allocator&gt;
std::basic_string&lt;typename iterator_traits&lt;RandomAccessIterator&gt;::value_type, traits, Allocator&gt;
<A href="#o81">operator</A> + (const std::basic_string&lt;typename iterator_traits&lt;RandomAccessIterator&gt;::value_type, traits, Allocator&gt;&amp; s,
const sub_match&lt;RandomAccessIterator&gt;&amp; m);
template &lt;class RandomAccessIterator, class traits, class Allocator&gt;
std::basic_string&lt;typename iterator_traits&lt;RandomAccessIterator&gt;::value_type, traits, Allocator&gt;
<A href="#o82">operator</A> + (const sub_match&lt;RandomAccessIterator&gt;&amp; m,
const std::basic_string&lt;typename iterator_traits&lt;RandomAccessIterator&gt;::value_type, traits, Allocator&gt;&amp; s);
template &lt;class RandomAccessIterator&gt; std::basic_string&lt;typename iterator_traits&lt;RandomAccessIterator&gt;::value_type&gt;
<A href="#o83">operator</A> + (typename iterator_traits&lt;RandomAccessIterator&gt;::value_type const* s,
const sub_match&lt;RandomAccessIterator&gt;&amp; m);
template &lt;class RandomAccessIterator&gt; std::basic_string&lt;typename iterator_traits&lt;RandomAccessIterator&gt;::value_type&gt;
<A href="#o84">operator</A> + (const sub_match&lt;RandomAccessIterator&gt;&amp; m,
typename iterator_traits&lt;RandomAccessIterator&gt;::value_type const * s);
template &lt;class RandomAccessIterator&gt;
std::basic_string&lt;typename iterator_traits&lt;RandomAccessIterator&gt;::value_type&gt;
<A href="#o85">operator</A> + (typename iterator_traits&lt;RandomAccessIterator&gt;::value_type const&amp; s,
const sub_match&lt;RandomAccessIterator&gt;&amp; m);
template &lt;class RandomAccessIterator&gt;
std::basic_string&lt;typename iterator_traits&lt;RandomAccessIterator&gt;::value_type&gt;
<A href="#o86">operator</A> + (const sub_match&lt;RandomAccessIterator&gt;&amp; m,
typename iterator_traits&lt;RandomAccessIterator&gt;::value_type const&amp; s);
template &lt;class RandomAccessIterator&gt;
std::basic_string&lt;typename iterator_traits&lt;RandomAccessIterator&gt;::value_type&gt;
<A href="#o87">operator</A> + (const sub_match&lt;RandomAccessIterator&gt;&amp; m1,
const sub_match&lt;RandomAccessIterator&gt;&amp; m2);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
std::basic_string&lt;typename iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;
<A href="#o81" >operator</A> + (const std::basic_string&lt;typename iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; s,
const sub_match&lt;BidirectionalIterator&gt;&amp; m);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
std::basic_string&lt;typename iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;
<A href="#o82" >operator</A> + (const sub_match&lt;BidirectionalIterator&gt;&amp; m,
const std::basic_string&lt;typename iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; s);
template &lt;class BidirectionalIterator&gt; std::basic_string&lt;typename iterator_traits&lt;BidirectionalIterator&gt;::value_type&gt;
<A href="#o83" >operator</A> + (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* s,
const sub_match&lt;BidirectionalIterator&gt;&amp; m);
template &lt;class BidirectionalIterator&gt; std::basic_string&lt;typename iterator_traits&lt;BidirectionalIterator&gt;::value_type&gt;
<A href="#o84" >operator</A> + (const sub_match&lt;BidirectionalIterator&gt;&amp; m,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const * s);
template &lt;class BidirectionalIterator&gt;
std::basic_string&lt;typename iterator_traits&lt;BidirectionalIterator&gt;::value_type&gt;
<A href="#o85" >operator</A> + (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; s,
const sub_match&lt;BidirectionalIterator&gt;&amp; m);
template &lt;class BidirectionalIterator&gt;
std::basic_string&lt;typename iterator_traits&lt;BidirectionalIterator&gt;::value_type&gt;
<A href="#o86" >operator</A> + (const sub_match&lt;BidirectionalIterator&gt;&amp; m,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; s);
template &lt;class BidirectionalIterator&gt;
std::basic_string&lt;typename iterator_traits&lt;BidirectionalIterator&gt;::value_type&gt;
<A href="#o87" >operator</A> + (const sub_match&lt;BidirectionalIterator&gt;&amp; m1,
const sub_match&lt;BidirectionalIterator&gt;&amp; m2);
//
// stream inserter:
//
template &lt;class charT, class traits, class BidirectionalIterator&gt;
basic_ostream&lt;charT, traits&gt;&amp;
<A href="#oi">operator</A> &lt;&lt; (basic_ostream&lt;charT, traits&gt;&amp; os,
<A href="#oi" >operator</A> &lt;&lt; (basic_ostream&lt;charT, traits&gt;&amp; os,
const sub_match&lt;BidirectionalIterator&gt;&amp; m);
} // namespace boost</PRE>
<H3>Description</H3>
<H4>
sub_match members</H4>
<H4>sub_match members</H4>
<PRE>typedef typename std::iterator_traits&lt;iterator&gt;::value_type value_type;</PRE>
<P>The type pointed to by the iterators.</P>
<PRE>typedef typename std::iterator_traits&lt;iterator&gt;::difference_type difference_type;</PRE>
@ -274,59 +284,77 @@ basic_ostream&lt;charT, traits&gt;&amp;
<PRE><A name=m1></A>bool matched</PRE>
<P>A Boolean value denoting whether this sub-expression participated in the match.</P>
<PRE><A name=m2></A>static difference_type length();</PRE>
<P>
<B>Effects: </B>returns the length of this matched sub-expression, or 0 if this
<P><B>Effects: </B>returns the length of this matched sub-expression, or 0 if this
sub-expression was not matched: <CODE>matched ? distance(first, second) : 0)</CODE>.</P>
<PRE><A name=m3></A>operator basic_string&lt;value_type&gt;()const;</PRE>
<P>
<B>Effects: </B>converts *this into a string: returns <CODE>(matched ?
<P><B>Effects: </B>converts *this into a string: returns <CODE>(matched ?
basic_string&lt;value_type&gt;(first, second) :
basic_string&lt;value_type&gt;()).</P>
</CODE><PRE><A name=m4></A>basic_string&lt;value_type&gt; str()const;</PRE>
<P><B> Effects: </B>returns a string representation of *this:&nbsp; <CODE>(matched ?
<P><B>Effects: </B>returns a string representation of *this:&nbsp; <CODE>(matched ?
basic_string&lt;value_type&gt;(first, second) :
basic_string&lt;value_type&gt;())</CODE>.</P>
<PRE><A name=m5></A>int compare(const sub_match&amp; s)const;</PRE>
<P>
<B>Effects: </B>performs a lexical comparison to <EM>s</EM>: returns <CODE>str().compare(s.str())</CODE>.</P>
<P><B>Effects: </B>performs a lexical comparison to <EM>s</EM>: returns <CODE>str().compare(s.str())</CODE>.</P>
<PRE><A name=m6></A>int compare(const basic_string&lt;value_type&gt;&amp; s)const;</PRE>
<P><B> Effects: </B>compares *this to the string s: returns <CODE>str().compare(s)</CODE>.</P>
<P><B>Effects: </B>compares *this to the string s: returns <CODE>str().compare(s)</CODE>.</P>
<PRE><A name=m7></A>int compare(const value_type* s)const;</PRE>
<P>
<B>Effects:<B></B> </B>compares *this to the null-terminated string <EM>s</EM>:<B>&nbsp;</B>returns
<P><B>Effects:<B></B> </B>compares *this to the null-terminated string <EM>s</EM>:<B>&nbsp;</B>returns
<CODE>str().compare(s)</CODE>.</P>
<H4>
sub_match non-member operators</H4>
<PRE><A name=m9></A>typedef implementation-private capture_sequence_type;</PRE>
<P>Defines an implementation-specific type that&nbsp;satisfies the requirements of
a standard library Sequence (21.1.1 including the optional Table 68
operations),&nbsp;whose value_type is a <EM>sub_match&lt;BidirectionalIterator&gt;</EM>.&nbsp;This
type happens to be <EM>std::vector&lt;sub_match&lt;BidirectionalIterator&gt; &gt;</EM>,
but you shouldn't actually rely on that.</P>
<PRE><A name=m8></A>const capture_sequence_type&amp; <A href="#m8" >captures</A>()const; </PRE>
<P><STRONG>Effects:</STRONG> returns a sequence containing all the captures
obtained for this sub-expression.</P>
<P><STRONG>Preconditions:</STRONG> the library must be built and used with
BOOST_REGEX_MATCH_EXTRA defined, and you must pass the flag <A href="match_flag_type.html">
match_extra</A> to the regex matching functions (<A href="regex_match.html">regex_match</A>,
<A href="regex_search.html">regex_search</A>, <A href="regex_iterator.html">regex_iterator</A>
or <A href="regex_token_iterator.html">regex_token_iterator</A>) in order for
this member function to be defined and return useful information.</P>
<P><STRONG>Rationale:</STRONG> Enabling this feature has several consequences:
</P>
<UL>
<LI>
sub_match occupies more memory resulting in complex expressions running out of
memory or stack space more quickly during matching.
<LI>
The matching algorithms are less efficient at handling some features
(independent sub-expressions for example), even when match_extra is not used.
<LI>
The matching algorithms are much less efficient (i.e. slower), when match_extra
is used.&nbsp; Mostly this is down to the extra memory allocations that have to
take place.</LI></UL>
<H4>sub_match non-member operators</H4>
<H5>Comparisons against self</H5>
<PRE><A name=o11></A>template &lt;class BidirectionalIterator&gt;
bool operator == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);</PRE>
<P>
<B>Effects: </B>returns <CODE>lhs.compare(rhs) == 0</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs.compare(rhs) == 0</CODE>.</P>
<PRE><A name=o12></A>template &lt;class BidirectionalIterator&gt;
bool operator != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);</PRE>
<P>
<B>Effects: </B>returns <CODE>lhs.compare(rhs) != 0</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs.compare(rhs) != 0</CODE>.</P>
<PRE><A name=o13></A>template &lt;class BidirectionalIterator&gt;
bool operator &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);</PRE>
<P>
<B>Effects: </B>returns <CODE>lhs.compare(rhs) &lt; 0</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs.compare(rhs) &lt; 0</CODE>.</P>
<PRE><A name=o14></A>template &lt;class BidirectionalIterator&gt;
bool operator &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);</PRE>
<P><B> Effects: </B>returns <CODE>lhs.compare(rhs) &lt;= 0</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs.compare(rhs) &lt;= 0</CODE>.</P>
<PRE><A name=o15></A>template &lt;class BidirectionalIterator&gt;
bool operator &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);</PRE>
<P>
<B>Effects: </B>returns <CODE>lhs.compare(rhs) &gt;= 0</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs.compare(rhs) &gt;= 0</CODE>.</P>
<PRE><A name=o16></A>template &lt;class BidirectionalIterator&gt;
bool operator &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);</PRE>
<P>
<B>Effects: </B>returns <CODE>lhs.compare(rhs) &gt; 0</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs.compare(rhs) &gt; 0</CODE>.</P>
<H5>Comparisons with std::basic_string</H5>
<pre><A name=o21></A>
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
@ -382,159 +410,135 @@ bool operator &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
<PRE><A name=o41></A>template &lt;class BidirectionalIterator&gt;
bool operator == (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs == rhs.str()</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs == rhs.str()</CODE>.</P>
<PRE><A name=o42></A>template &lt;class BidirectionalIterator&gt;
bool operator != (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs != rhs.str()</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs != rhs.str()</CODE>.</P>
<PRE></A><A name=o43></A>template &lt;class BidirectionalIterator&gt;
bool operator &lt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs &lt; rhs.str()</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs &lt; rhs.str()</CODE>.</P>
<PRE><A name=o44></A>template &lt;class BidirectionalIterator&gt;
bool operator &gt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs &gt; rhs.str()</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs &gt; rhs.str()</CODE>.</P>
<PRE><A name=o45></A>template &lt;class BidirectionalIterator&gt;
bool operator &gt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs &gt;= rhs.str()</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs &gt;= rhs.str()</CODE>.</P>
<PRE><A name=o46></A>template &lt;class BidirectionalIterator&gt;
bool operator &lt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs &lt;= rhs.str()</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs &lt;= rhs.str()</CODE>.</P>
<PRE><A name=o51></A>template &lt;class BidirectionalIterator&gt;
bool operator == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs.str() == rhs</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs.str() == rhs</CODE>.</P>
<PRE><A name=o52></A>template &lt;class BidirectionalIterator&gt;
bool operator != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs.str() != rhs</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs.str() != rhs</CODE>.</P>
<PRE><A name=o53></A>template &lt;class BidirectionalIterator&gt;
bool operator &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs.str() &lt; rhs</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs.str() &lt; rhs</CODE>.</P>
<PRE><A name=o54></A>template &lt;class BidirectionalIterator&gt;
bool operator &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs.str() &gt; rhs</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs.str() &gt; rhs</CODE>.</P>
<PRE><A name=o55></A>template &lt;class BidirectionalIterator&gt;
bool operator &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs.str() &gt;= rhs</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs.str() &gt;= rhs</CODE>.</P>
<PRE><A name=o56></A>template &lt;class BidirectionalIterator&gt;
bool operator &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs.str() &lt;= rhs</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs.str() &lt;= rhs</CODE>.</P>
<H5>Comparisons with a single character</H5>
<PRE><A name=o61></A>template &lt;class BidirectionalIterator&gt;
bool operator == (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs == rhs.str()</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs == rhs.str()</CODE>.</P>
<PRE><A name=o62></A>template &lt;class BidirectionalIterator&gt;
bool operator != (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs != rhs.str()</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs != rhs.str()</CODE>.</P>
<PRE><A name=o63></A>template &lt;class BidirectionalIterator&gt;
bool operator &lt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs &lt; rhs.str()</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs &lt; rhs.str()</CODE>.</P>
<PRE><A name=o64></A>template &lt;class BidirectionalIterator&gt;
bool operator &gt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs &gt; rhs.str()</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs &gt; rhs.str()</CODE>.</P>
<PRE><A name=o65></A>template &lt;class BidirectionalIterator&gt;
bool operator &gt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs &gt;= rhs.str()</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs &gt;= rhs.str()</CODE>.</P>
<PRE><A name=o66></A>template &lt;class BidirectionalIterator&gt;
bool operator &lt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs &lt;= rhs.str()</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs &lt;= rhs.str()</CODE>.</P>
<PRE><A name=o71></A>template &lt;class BidirectionalIterator&gt;
bool operator == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs.str() == rhs</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs.str() == rhs</CODE>.</P>
<PRE><A name=o72></A>template &lt;class BidirectionalIterator&gt;
bool operator != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs.str() != rhs</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs.str() != rhs</CODE>.</P>
<PRE><A name=o73></A>template &lt;class BidirectionalIterator&gt;
bool operator &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs.str() &lt; rhs</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs.str() &lt; rhs</CODE>.</P>
<PRE><A name=o74></A>template &lt;class BidirectionalIterator&gt;
bool operator &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs.str() &gt; rhs</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs.str() &gt; rhs</CODE>.</P>
<PRE><A name=o75></A>template &lt;class BidirectionalIterator&gt;
bool operator &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs.str() &gt;= rhs</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs.str() &gt;= rhs</CODE>.</P>
<PRE><A name=o76></A>template &lt;class BidirectionalIterator&gt;
bool operator &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs); </PRE>
<P>
<B>Effects: </B>returns <CODE>lhs.str() &lt;= rhs</CODE>.</P>
<P><B>Effects: </B>returns <CODE>lhs.str() &lt;= rhs</CODE>.</P>
<h5>Addition operators</h5>
<P>The addition operators for sub_match allow you to add a sub_match to any type
to which you can add a std::string and obtain a new string as the result.</P>
<PRE><A name=o81></A>template &lt;class RandomAccessIterator, class traits, class Allocator&gt;
std::basic_string&lt;typename iterator_traits&lt;RandomAccessIterator&gt;::value_type, traits, Allocator&gt;
operator + (const std::basic_string&lt;typename iterator_traits&lt;RandomAccessIterator&gt;::value_type, traits, Allocator&gt;&amp; s,
const sub_match&lt;RandomAccessIterator&gt;&amp; m); </PRE>
<PRE><A name=o81></A>template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
std::basic_string&lt;typename iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;
operator + (const std::basic_string&lt;typename iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; s,
const sub_match&lt;BidirectionalIterator&gt;&amp; m); </PRE>
<P><B>Effects: </B>returns <CODE>s + m.str()</CODE>.</P>
<PRE><A name=o82></A>template &lt;class RandomAccessIterator, class traits, class Allocator&gt;
std::basic_string&lt;typename iterator_traits&lt;RandomAccessIterator&gt;::value_type, traits, Allocator&gt;
operator + (const sub_match&lt;RandomAccessIterator&gt;&amp; m,
const std::basic_string&lt;typename iterator_traits&lt;RandomAccessIterator&gt;::value_type, traits, Allocator&gt;&amp; s); </PRE>
<PRE><A name=o82></A>template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
std::basic_string&lt;typename iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;
operator + (const sub_match&lt;BidirectionalIterator&gt;&amp; m,
const std::basic_string&lt;typename iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; s); </PRE>
<P><B>Effects: </B>returns <CODE>m.str() + s</CODE>.</P>
<PRE><A name=o83></A>template &lt;class RandomAccessIterator&gt; std::basic_string&lt;typename iterator_traits&lt;RandomAccessIterator&gt;::value_type&gt;
operator + (typename iterator_traits&lt;RandomAccessIterator&gt;::value_type const* s,
const sub_match&lt;RandomAccessIterator&gt;&amp; m); </PRE>
<PRE><A name=o83></A>template &lt;class BidirectionalIterator&gt; std::basic_string&lt;typename iterator_traits&lt;BidirectionalIterator&gt;::value_type&gt;
operator + (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* s,
const sub_match&lt;BidirectionalIterator&gt;&amp; m); </PRE>
<P><B>Effects: </B>returns <CODE>s + m.str()</CODE>.</P>
<PRE><A name=o84></A>template &lt;class RandomAccessIterator&gt; std::basic_string&lt;typename iterator_traits&lt;RandomAccessIterator&gt;::value_type&gt;
operator + (const sub_match&lt;RandomAccessIterator&gt;&amp; m,
typename iterator_traits&lt;RandomAccessIterator&gt;::value_type const * s);</PRE>
<PRE><A name=o84></A>template &lt;class BidirectionalIterator&gt; std::basic_string&lt;typename iterator_traits&lt;BidirectionalIterator&gt;::value_type&gt;
operator + (const sub_match&lt;BidirectionalIterator&gt;&amp; m,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const * s);</PRE>
<P><B>Effects: </B>returns <CODE>m.str() + s</CODE>.</P>
<PRE><A name=o85></A>template &lt;class RandomAccessIterator&gt;
std::basic_string&lt;typename iterator_traits&lt;RandomAccessIterator&gt;::value_type&gt;
operator + (typename iterator_traits&lt;RandomAccessIterator&gt;::value_type const&amp; s,
const sub_match&lt;RandomAccessIterator&gt;&amp; m); </PRE>
<PRE><A name=o85></A>template &lt;class BidirectionalIterator&gt;
std::basic_string&lt;typename iterator_traits&lt;BidirectionalIterator&gt;::value_type&gt;
operator + (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; s,
const sub_match&lt;BidirectionalIterator&gt;&amp; m); </PRE>
<P><B>Effects: </B>returns <CODE>s + m.str()</CODE>.</P>
<PRE><A name=o86></A>template &lt;class RandomAccessIterator&gt;
std::basic_string&lt;typename iterator_traits&lt;RandomAccessIterator&gt;::value_type&gt;
operator + (const sub_match&lt;RandomAccessIterator&gt;&amp; m,
typename iterator_traits&lt;RandomAccessIterator&gt;::value_type const&amp; s); </PRE>
<PRE><A name=o86></A>template &lt;class BidirectionalIterator&gt;
std::basic_string&lt;typename iterator_traits&lt;BidirectionalIterator&gt;::value_type&gt;
operator + (const sub_match&lt;BidirectionalIterator&gt;&amp; m,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; s); </PRE>
<P><B>Effects: </B>returns <CODE>m.str() + s</CODE>.</P>
<PRE><A name=o87></A>template &lt;class RandomAccessIterator&gt;
std::basic_string&lt;typename iterator_traits&lt;RandomAccessIterator&gt;::value_type&gt;
operator + (const sub_match&lt;RandomAccessIterator&gt;&amp; m1,
const sub_match&lt;RandomAccessIterator&gt;&amp; m2);</PRE>
<PRE><A name=o87></A>template &lt;class BidirectionalIterator&gt;
std::basic_string&lt;typename iterator_traits&lt;BidirectionalIterator&gt;::value_type&gt;
operator + (const sub_match&lt;BidirectionalIterator&gt;&amp; m1,
const sub_match&lt;BidirectionalIterator&gt;&amp; m2);</PRE>
<P><B>Effects: </B>returns&nbsp;<CODE>m1.str() + m2.str()</CODE>.</P>
<h5>Stream inserter</h5>
<PRE><A name=oi></A>template &lt;class charT, class traits, class BidirectionalIterator&gt;
@ -549,10 +553,10 @@ basic_ostream&lt;charT, traits&gt;&amp;
24 Oct 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
<p><i><EFBFBD> Copyright John Maddock&nbsp;1998-
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
<P><I>Use, modification and distribution are subject to the Boost Software License,
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
</body>
</html>

View File

@ -45,6 +45,23 @@ test-suite regex-examples :
[ regex-test-run snippets/regex_token_iterator_eg_2.cpp : $(BOOST_ROOT)/libs/regex/doc/index.html ]
[ regex-test-run snippets/regex_iterator_example.cpp : $(BOOST_ROOT)/boost/rational.hpp ]
[ run
# sources
snippets/captures_example.cpp
<template>../build/regex-options
# dependencies
<lib>../test/captures/boost_regex_extra
: # additional args
: # test-files
: # requirements
<threading>multi
<define>BOOST_REGEX_MATCH_EXTRA=1
<define>BOOST_REGEX_NO_LIB=1
: # test name
captures_example
]
;
@ -54,3 +71,5 @@ test-suite regex-examples :

View File

@ -0,0 +1,51 @@
#include <boost/regex.hpp>
#include <iostream>
void print_captures(const std::string& regx, const std::string& text)
{
boost::regex e(regx);
boost::smatch what;
std::cout << "Expression: \"" << regx << "\"\n";
std::cout << "Text: \"" << text << "\"\n";
if(boost::regex_match(text, what, e, boost::match_extra))
{
unsigned i, j;
std::cout << "** Match found **\n Sub-Expressions:\n";
for(i = 0; i < what.size(); ++i)
std::cout << " $" << i << " = \"" << what[i] << "\"\n";
std::cout << " Captures:\n";
for(i = 0; i < what.size(); ++i)
{
std::cout << " $" << i << " = {";
for(j = 0; j < what.captures(i).size(); ++j)
{
if(j)
std::cout << ", ";
else
std::cout << " ";
std::cout << "\"" << what.captures(i)[j] << "\"";
}
std::cout << " }\n";
}
}
else
{
std::cout << "** No Match found **\n";
}
}
int main(int , char* [])
{
print_captures("(([[:lower:]]+)|([[:upper:]]+))+", "aBBcccDDDDDeeeeeeee");
print_captures("a(b+|((c)*))+d", "abd");
print_captures("(.*)bar|(.*)bah", "abcbar");
print_captures("(.*)bar|(.*)bah", "abcbah");
print_captures("^(?:(\\w+)|(?>\\W+))*$", "now is the time for all good men to come to the aid of the party");
print_captures("^(?>(\\w+)\\W*)*$", "now is the time for all good men to come to the aid of the party");
print_captures("^(\\w+)\\W+(?>(\\w+)\\W+)*(\\w+)$", "now is the time for all good men to come to the aid of the party");
print_captures("^(\\w+)\\W+(?>(\\w+)\\W+(?:(\\w+)\\W+){0,2})*(\\w+)$", "now is the time for all good men to come to the aid of the party");
return 0;
}

View File

@ -55,12 +55,10 @@
# include <boost/detail/allocator.hpp>
# include <boost/regex/config/cstring.hpp>
# include <boost/throw_exception.hpp>
# include <boost/scoped_ptr.hpp>
# ifndef BOOST_NO_STD_LOCALE
# include <locale>
# endif
# ifdef BOOST_REGEX_MATCH_EXTRA
# include <boost/scoped_ptr.hpp>
# endif
#else
//
// C build,

View File

@ -85,3 +85,8 @@
// if you don't want boost.regex to cache memory.
// #define BOOST_REGEX_MAX_CACHE_BLOCKS 16
// define this if you want to be able to access extended capture
// information in your sub_match's (caution this will slow things
// down quite a bit).
// #define BOOST_REGEX_MATCH_EXTRA

View File

@ -55,7 +55,12 @@ typedef enum _match_flags
match_perl = match_all << 1, // Use perl matching rules
match_posix = match_perl << 1, // Use POSIX matching rules
match_nosubs = match_posix << 1, // don't trap marked subs
match_max = match_nosubs,
match_extra = match_nosubs << 1, // include full capture information for repeated captures
match_single_line = match_extra << 1, // treat text as single line and ignor any \n's when matching ^ and $.
match_unused1 = match_single_line << 1, // unused
match_unused2 = match_unused1 << 1, // unused
match_unused3 = match_unused2 << 1, // unused
match_max = match_unused3,
format_perl = 0, // perl style replacement
format_default = 0, // ditto.
@ -117,6 +122,8 @@ using regex_constants::match_all;
using regex_constants::match_perl;
using regex_constants::match_posix;
using regex_constants::match_nosubs;
using regex_constants::match_extra;
using regex_constants::match_single_line;
//using regex_constants::match_max;
using regex_constants::format_all;
using regex_constants::format_sed;

View File

@ -25,19 +25,19 @@
namespace boost{
template <class RandomAccessIterator
, class Allocator = BOOST_DEFAULT_ALLOCATOR(sub_match<RandomAccessIterator> )
template <class BidiIterator
, class Allocator = BOOST_DEFAULT_ALLOCATOR(sub_match<BidiIterator> )
>
class match_results
{
private:
#ifndef BOOST_NO_STD_ALLOCATOR
typedef std::vector<sub_match<RandomAccessIterator>, Allocator> vector_type;
typedef std::vector<sub_match<BidiIterator>, Allocator> vector_type;
#else
typedef std::vector<sub_match<RandomAccessIterator> > vector_type;
typedef std::vector<sub_match<BidiIterator> > vector_type;
#endif
public:
typedef sub_match<RandomAccessIterator> value_type;
typedef sub_match<BidiIterator> value_type;
#if !defined(BOOST_NO_STD_ALLOCATOR) && !(defined(BOOST_MSVC) && defined(_STLPORT_VERSION))
typedef typename Allocator::const_reference const_reference;
#else
@ -47,11 +47,11 @@ public:
typedef typename vector_type::const_iterator const_iterator;
typedef const_iterator iterator;
typedef typename re_detail::regex_iterator_traits<
RandomAccessIterator>::difference_type difference_type;
BidiIterator>::difference_type difference_type;
typedef typename Allocator::size_type size_type;
typedef Allocator allocator_type;
typedef typename re_detail::regex_iterator_traits<
RandomAccessIterator>::value_type char_type;
BidiIterator>::value_type char_type;
typedef std::basic_string<char_type> string_type;
// construct/copy/destroy:
@ -91,10 +91,10 @@ public:
sub += 2;
if(sub < m_subs.size())
{
const sub_match<RandomAccessIterator>& s = m_subs[sub];
const sub_match<BidiIterator>& s = m_subs[sub];
if(s.matched)
{
return boost::re_detail::distance((RandomAccessIterator)(m_base), (RandomAccessIterator)(s.first));
return boost::re_detail::distance((BidiIterator)(m_base), (BidiIterator)(s.first));
}
}
return ~static_cast<difference_type>(0);
@ -105,7 +105,7 @@ public:
string_type result;
if(sub < (int)m_subs.size() && (sub > 0))
{
const sub_match<RandomAccessIterator>& s = m_subs[sub];
const sub_match<BidiIterator>& s = m_subs[sub];
if(s.matched)
{
result = s;
@ -174,9 +174,18 @@ public:
bool operator!=(const match_results& that)const
{ return !(*this == that); }
#ifdef BOOST_REGEX_MATCH_EXTRA
typedef typename sub_match<BidiIterator>::capture_sequence_type capture_sequence_type;
const capture_sequence_type& captures(int i)const
{
return (*this)[i].captures();
}
#endif
//
// private access functions:
void BOOST_REGEX_CALL set_second(RandomAccessIterator i)
void BOOST_REGEX_CALL set_second(BidiIterator i)
{
assert(m_subs.size() > 2);
m_subs[2].second = i;
@ -188,7 +197,7 @@ public:
m_null.matched = false;
}
void BOOST_REGEX_CALL set_second(RandomAccessIterator i, size_type pos, bool m = true)
void BOOST_REGEX_CALL set_second(BidiIterator i, size_type pos, bool m = true)
{
pos += 2;
assert(m_subs.size() > pos);
@ -203,7 +212,7 @@ public:
m_null.matched = false;
}
}
void BOOST_REGEX_CALL set_size(size_type n, RandomAccessIterator i, RandomAccessIterator j)
void BOOST_REGEX_CALL set_size(size_type n, BidiIterator i, BidiIterator j)
{
value_type v(j);
size_type len = m_subs.size();
@ -220,11 +229,11 @@ public:
}
m_subs[1].first = i;
}
void BOOST_REGEX_CALL set_base(RandomAccessIterator pos)
void BOOST_REGEX_CALL set_base(BidiIterator pos)
{
m_base = pos;
}
void BOOST_REGEX_CALL set_first(RandomAccessIterator i)
void BOOST_REGEX_CALL set_first(BidiIterator i)
{
// set up prefix:
m_subs[1].second = i;
@ -238,7 +247,7 @@ public:
m_subs[n].matched = false;
}
}
void BOOST_REGEX_CALL set_first(RandomAccessIterator i, size_type pos)
void BOOST_REGEX_CALL set_first(BidiIterator i, size_type pos)
{
assert(pos+2 < m_subs.size());
if(pos)
@ -246,22 +255,22 @@ public:
else
set_first(i);
}
void BOOST_REGEX_CALL maybe_assign(const match_results<RandomAccessIterator, Allocator>& m);
void BOOST_REGEX_CALL maybe_assign(const match_results<BidiIterator, Allocator>& m);
private:
vector_type m_subs; // subexpressions
RandomAccessIterator m_base; // where the search started from
sub_match<RandomAccessIterator> m_null; // a null match
BidiIterator m_base; // where the search started from
sub_match<BidiIterator> m_null; // a null match
};
template <class RandomAccessIterator, class Allocator>
void BOOST_REGEX_CALL match_results<RandomAccessIterator, Allocator>::maybe_assign(const match_results<RandomAccessIterator, Allocator>& m)
template <class BidiIterator, class Allocator>
void BOOST_REGEX_CALL match_results<BidiIterator, Allocator>::maybe_assign(const match_results<BidiIterator, Allocator>& m)
{
const_iterator p1, p2;
p1 = begin();
p2 = m.begin();
RandomAccessIterator base = (*this)[-1].first;
BidiIterator base = (*this)[-1].first;
std::size_t len1 = 0;
std::size_t len2 = 0;
std::size_t base1 = 0;
@ -276,8 +285,8 @@ void BOOST_REGEX_CALL match_results<RandomAccessIterator, Allocator>::maybe_assi
if(base1 < base2) return;
if(base2 < base1) break;
len1 = boost::re_detail::distance((RandomAccessIterator)p1->first, (RandomAccessIterator)p1->second);
len2 = boost::re_detail::distance((RandomAccessIterator)p2->first, (RandomAccessIterator)p2->second);
len1 = boost::re_detail::distance((BidiIterator)p1->first, (BidiIterator)p1->second);
len2 = boost::re_detail::distance((BidiIterator)p2->first, (BidiIterator)p2->second);
if((len1 != len2) || ((p1->matched == false) && (p2->matched == true)))
break;
if((p1->matched == true) && (p2->matched == false))
@ -293,24 +302,24 @@ void BOOST_REGEX_CALL match_results<RandomAccessIterator, Allocator>::maybe_assi
*this = m;
}
template <class RandomAccessIterator, class Allocator>
void swap(match_results<RandomAccessIterator, Allocator>& a, match_results<RandomAccessIterator, Allocator>& b)
template <class BidiIterator, class Allocator>
void swap(match_results<BidiIterator, Allocator>& a, match_results<BidiIterator, Allocator>& b)
{
a.swap(b);
}
#ifndef BOOST_NO_STD_LOCALE
template <class charT, class traits, class RandomAccessIterator, class Allocator>
template <class charT, class traits, class BidiIterator, class Allocator>
std::basic_ostream<charT, traits>&
operator << (std::basic_ostream<charT, traits>& os,
const match_results<RandomAccessIterator, Allocator>& s)
const match_results<BidiIterator, Allocator>& s)
{
return (os << s.str());
}
#else
template <class RandomAccessIterator, class Allocator>
template <class BidiIterator, class Allocator>
std::ostream& operator << (std::ostream& os,
const match_results<RandomAccessIterator, Allocator>& s)
const match_results<BidiIterator, Allocator>& s)
{
return (os << s.str());
}

View File

@ -13,7 +13,6 @@
#define BOOST_REGEX_MATCHER_HPP
#include <boost/regex/v4/iterator_category.hpp>
#include <boost/scoped_ptr.hpp>
#ifdef BOOST_HAS_ABI_HEADERS
# include BOOST_ABI_PREFIX
@ -22,7 +21,13 @@
namespace boost{
namespace re_detail{
//
//
// error checking API:
//
BOOST_REGEX_DECL void BOOST_REGEX_CALL verify_options(boost::regex::flag_type ef, match_flag_type mf);
//
// Unfortunately Rogue Waves standard library appears to have a bug
// in std::basic_string::compare that results in eroneous answers
// in some cases (tested with Borland C++ 5.1, Rogue Wave lib version

View File

@ -117,6 +117,7 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match()
m_presult->set_base(base);
if(m_match_flags & match_posix)
m_result = *m_presult;
verify_options(re.flags(), m_match_flags);
if(0 == match_prefix())
return false;
return m_result[0].second == last;
@ -206,6 +207,7 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::find()
m_result.set_base(base);
}
verify_options(re.flags(), m_match_flags);
// find out what kind of expression we have:
unsigned type = (m_match_flags & match_continuous) ?
static_cast<unsigned int>(regbase::restart_continue)
@ -253,6 +255,19 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_prefix()
m_presult->set_second(last, 0, false);
position = last;
}
#ifdef BOOST_REGEX_MATCH_EXTRA
if(m_has_found_match && (match_extra & m_match_flags))
{
//
// we have a match, reverse the capture information:
//
for(unsigned i = 0; i < m_presult->size(); ++i)
{
typename sub_match<BidiIterator>::capture_sequence_type & seq = ((*m_presult)[i]).get_captures();
std::reverse(seq.begin(), seq.end());
}
}
#endif
if(!m_has_found_match)
position = restart; // reset search postion
return m_has_found_match;
@ -297,15 +312,20 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_literal()
template <class BidiIterator, class Allocator, class traits, class Allocator2>
bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_start_line()
{
if((position == base) && ((m_match_flags & match_prev_avail) == 0))
if(position == base)
{
if((m_match_flags & match_not_bol) == 0)
if((m_match_flags & match_prev_avail) == 0)
{
pstate = pstate->next.p;
return true;
if((m_match_flags & match_not_bol) == 0)
{
pstate = pstate->next.p;
return true;
}
return false;
}
return false;
}
else if(m_match_flags & match_single_line)
return false;
// check the previous value character:
BidiIterator t(position);
@ -331,6 +351,8 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_end_line()
{
if(position != last)
{
if(m_match_flags & match_single_line)
return false;
// we're not yet at the end so *first is always valid:
if(traits_inst.is_separator(*position))
{
@ -387,6 +409,14 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_match()
m_result.maybe_assign(*m_presult);
return false;
}
#ifdef BOOST_REGEX_MATCH_EXTRA
if(match_extra & m_match_flags)
{
for(unsigned i = 0; i < m_presult->size(); ++i)
if((*m_presult)[i].matched)
((*m_presult)[i]).get_captures().push_back((*m_presult)[i]);
}
#endif
return true;
}

View File

@ -309,11 +309,38 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_startmark(
}
case -3:
{
// independent sub-expression:
// independent sub-expression, currently this is always recursive:
const re_syntax_base* next_pstate = static_cast<const re_jump*>(pstate->next.p)->alt.p->next.p;
pstate = pstate->next.p->next.p;
bool r = match_all_states();
pstate = next_pstate;
#ifdef BOOST_REGEX_MATCH_EXTRA
if(r && (m_match_flags & match_extra))
{
//
// our captures have been stored in *m_presult
// we need to unpack them, and insert them
// back in the right order when we unwind the stack:
//
match_results<BidiIterator, Allocator> tm(*m_presult);
unsigned i;
for(i = 0; i < tm.size(); ++i)
(*m_presult)[i].get_captures().clear();
// match everything else:
r = match_all_states();
// now place the stored captures back:
for(i = 0; i < tm.size(); ++i)
{
typedef typename sub_match<BidiIterator>::capture_sequence_type seq;
seq& s1 = (*m_presult)[i].get_captures();
const seq& s2 = tm[i].captures();
s1.insert(
s1.end(),
s2.begin(),
s2.end());
}
}
#endif
return r;
}
default:
@ -809,6 +836,13 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::unwind_paren(boo
m_presult->set_first(pmp->sub.first, pmp->index);
m_presult->set_second(pmp->sub.second, pmp->index, pmp->sub.matched);
}
#ifdef BOOST_REGEX_MATCH_EXTRA
//
// we have a match, push the capture information onto the stack:
//
else if(pmp->sub.matched && (match_extra & m_match_flags))
((*m_presult)[pmp->index]).get_captures().push_back(pmp->sub);
#endif
// unwind stack:
m_backup_state = pmp+1;
boost::re_detail::inplace_destroy(pmp);

View File

@ -35,13 +35,14 @@ class backup_subex
public:
template <class A>
backup_subex(const match_results<BidiIterator, A>& w, int i)
: index(i), sub(w[i]) {}
: index(i), sub(w[i], false) {}
template <class A>
void restore(match_results<BidiIterator, A>& w)
{
w.set_first(sub.first, index);
w.set_second(sub.second, index, sub.matched);
}
const sub_match<BidiIterator>& get() { return sub; }
};
template <class BidiIterator, class Allocator, class traits, class Allocator2>
@ -126,6 +127,33 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_startmark(
pstate = pstate->next.p->next.p;
r = match_all_states();
pstate = next_pstate;
#ifdef BOOST_REGEX_MATCH_EXTRA
if(r && (m_match_flags & match_extra))
{
//
// our captures have been stored in *m_presult
// we need to unpack them, and insert them
// back in the right order when we unwind the stack:
//
unsigned i;
match_results<BidiIterator, Allocator> tm(*m_presult);
for(i = 0; i < tm.size(); ++i)
(*m_presult)[i].get_captures().clear();
// match everything else:
r = match_all_states();
// now place the stored captures back:
for(i = 0; i < tm.size(); ++i)
{
typedef typename sub_match<BidiIterator>::capture_sequence_type seq;
seq& s1 = (*m_presult)[i].get_captures();
const seq& s2 = tm[i].captures();
s1.insert(
s1.end(),
s2.begin(),
s2.end());
}
}
#endif
break;
}
default:
@ -139,6 +167,13 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_startmark(
r = match_all_states();
if(r == false)
sub.restore(*m_presult);
#ifdef BOOST_REGEX_MATCH_EXTRA
//
// we have a match, push the capture information onto the stack:
//
else if(sub.get().matched && (match_extra & m_match_flags))
((*m_presult)[index]).get_captures().push_back(sub.get());
#endif
}
else
{

View File

@ -103,22 +103,14 @@ public:
if(regex_search(first, end, what, *pre, flags) == true)
{
N = 0;
#if 1
result = ((subs[N] == -1) ? what.prefix() : what[(int)subs[N]]);
#else
result = ((subs[N] == -1) ? value_type(what.prefix().str()) : value_type(what[(int)subs[N]].str()));
#endif
return true;
}
else if((subs[N] == -1) && (first != end))
{
#if 1
result.first = first;
result.second = end;
result.matched = (first != end);
#else
result = value_type(first, end);
#endif
return true;
}
return false;
@ -142,11 +134,7 @@ public:
if(N+1 < (int)subs.size())
{
++N;
#if 1
result =((subs[N] == -1) ? what.prefix() : what[subs[N]]);
#else
result =((subs[N] == -1) ? value_type(what.prefix().first, what.prefix().second) : value_type(what[subs[N]].first, what[subs[N]].second));
#endif
return true;
}
if(what.prefix().first != what[0].second)
@ -155,23 +143,15 @@ public:
if(regex_search(last_end, end, what, *pre, ((what[0].first == what[0].second) ? flags | regex_constants::match_not_initial_null : flags)))
{
N =0;
#if 1
result =((subs[N] == -1) ? what.prefix() : what[subs[N]]);
#else
result =((subs[N] == -1) ? value_type(what.prefix().first, what.prefix().second) : value_type(what[subs[N]].first, what[subs[N]].second));
#endif
return true;
}
else if((last_end != end) && (subs[0] == -1))
{
N =-1;
#if 1
result.first = last_end;
result.second = end;
result.matched = (last_end != end);
#else
result = value_type(last_end, end);
#endif
return true;
}
return false;
@ -189,11 +169,7 @@ private:
typedef shared_ptr<impl> pimpl;
public:
typedef basic_regex<charT, traits, Allocator> regex_type;
#if 1
typedef sub_match<BidirectionalIterator> value_type;
#else
typedef std::basic_string<charT> value_type;
#endif
typedef typename re_detail::regex_iterator_traits<BidirectionalIterator>::difference_type
difference_type;
typedef const value_type* pointer;

View File

@ -83,6 +83,58 @@ struct sub_match : public std::pair<BidiIterator, BidiIterator>
bool operator>=(const sub_match& that)const
{ return compare(that) >= 0; }
#ifdef BOOST_REGEX_MATCH_EXTRA
typedef std::vector<sub_match<BidiIterator> > capture_sequence_type;
const capture_sequence_type& captures()const
{
if(!m_captures)
m_captures.reset(new capture_sequence_type());
return *m_captures;
}
//
// Private implementation API: DO NOT USE!
//
capture_sequence_type& get_captures()const
{
if(!m_captures)
m_captures.reset(new capture_sequence_type());
return *m_captures;
}
private:
mutable boost::scoped_ptr<capture_sequence_type> m_captures;
public:
#endif
sub_match(const sub_match& that, bool
#ifdef BOOST_REGEX_MATCH_EXTRA
deep_copy
#endif
= true
)
: std::pair<BidiIterator, BidiIterator>(that),
matched(that.matched)
{
#ifdef BOOST_REGEX_MATCH_EXTRA
if(that.m_captures)
if(deep_copy)
m_captures.reset(new capture_sequence_type(*(that.m_captures)));
#endif
}
sub_match& operator=(const sub_match& that)
{
this->first = that.first;
this->second = that.second;
matched = that.matched;
#ifdef BOOST_REGEX_MATCH_EXTRA
if(that.m_captures)
get_captures() = *(that.m_captures);
#endif
return *this;
}
#ifdef BOOST_OLD_REGEX_H
//
// the following are deprecated, do not use!!

View File

@ -55,6 +55,21 @@ regbase::regbase(const regbase& b)
namespace re_detail{
//
// error checking API:
//
BOOST_REGEX_DECL void BOOST_REGEX_CALL verify_options(boost::regex::flag_type /*ef*/, match_flag_type mf)
{
//
// can't mix match_extra with POSIX matching rules:
//
if((mf & match_extra) && (mf & match_posix))
{
std::logic_error msg("Usage Error: Can't mix regular expression captures with POSIX matching rules");
throw_exception(msg);
}
}
#ifdef BOOST_REGEX_HAS_MS_STACK_GUARD
BOOST_REGEX_DECL void BOOST_REGEX_CALL reset_stack_guard_page()

View File

@ -4,6 +4,7 @@ subproject libs/regex/test ;
# bring in the rules for testing
import testing ;
subinclude libs/regex/test/captures ;
#
# this template defines the options common to
@ -130,6 +131,24 @@ test-suite regex
]
[ compile concepts/wide_concept_check.cpp
]
[ run
# sources
captures/captures_test.cpp
<template>../build/regex-options
# dependencies
<lib>captures/boost_regex_extra
<lib>../../test/build/boost_test_exec_monitor
: # additional args
: # test-files
: # requirements
<threading>multi
<define>BOOST_REGEX_MATCH_EXTRA=1
<define>BOOST_REGEX_NO_LIB=1
: # test name
captures_test
]
;
@ -139,3 +158,7 @@ test-suite regex

16
test/captures/Jamfile Normal file
View File

@ -0,0 +1,16 @@
# copyright John Maddock 2003
subproject libs/regex/test/captures ;
EX_SOURCES = c_regex_traits c_regex_traits_common cpp_regex_traits
cregex fileiter posix_api regex regex_debug
regex_synch w32_regex_traits wide_posix_api instances winstances ;
lib boost_regex_extra : ../../src/$(EX_SOURCES).cpp <template>../../build/regex-options
:
<define>BOOST_REGEX_MATCH_EXTRA=1
:
;

View File

@ -0,0 +1,90 @@
#include <boost/regex.hpp>
#include <boost/test/test_tools.hpp>
#include <boost/array.hpp>
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
template <class T>
void test_captures(const std::string& regx, const std::string& text, T& expected)
{
boost::regex e(regx);
boost::smatch what;
if(boost::regex_match(text, what, e, boost::match_extra))
{
unsigned i, j;
BOOST_TEST(what.size() == ARRAY_SIZE(expected));
for(i = 0; i < what.size(); ++i)
{
BOOST_TEST(what.captures(i).size() <= ARRAY_SIZE(expected[i]));
for(j = 0; j < what.captures(i).size(); ++j)
{
BOOST_TEST(what.captures(i)[j] == expected[i][j]);
}
}
}
}
int test_main(int , char* [])
{
typedef const char* pchar;
pchar e1[4][5] =
{
{ "aBBcccDDDDDeeeeeeee", },
{ "a", "BB", "ccc", "DDDDD", "eeeeeeee", },
{ "a", "ccc", "eeeeeeee", },
{ "BB", "DDDDD", },
};
test_captures("(([[:lower:]]+)|([[:upper:]]+))+", "aBBcccDDDDDeeeeeeee", e1);
pchar e2[4][2] =
{
{ "abd" },
{ "b", "" },
{ "" },
};
test_captures("a(b+|((c)*))+d", "abd", e2);
pchar e3[3][1] =
{
{ "abcbar" },
{ "abc" },
};
test_captures("(.*)bar|(.*)bah", "abcbar", e3);
pchar e4[3][1] =
{
{ "abcbah" },
{ 0, },
{ "abc" },
};
test_captures("(.*)bar|(.*)bah", "abcbah", e4);
pchar e5[2][16] =
{
{ "now is the time for all good men to come to the aid of the party" },
{ "now", "is", "the", "time", "for", "all", "good", "men", "to", "come", "to", "the", "aid", "of", "the", "party" },
};
test_captures("^(?:(\\w+)|(?>\\W+))*$", "now is the time for all good men to come to the aid of the party", e5);
pchar e6[2][16] =
{
{ "now is the time for all good men to come to the aid of the party" },
{ "now", "is", "the", "time", "for", "all", "good", "men", "to", "come", "to", "the", "aid", "of", "the", "party" },
};
test_captures("^(?>(\\w+)\\W*)*$", "now is the time for all good men to come to the aid of the party", e6);
pchar e7[4][14] =
{
{ "now is the time for all good men to come to the aid of the party" },
{ "now" },
{ "is", "the", "time", "for", "all", "good", "men", "to", "come", "to", "the", "aid", "of", "the" },
{ "party" },
};
test_captures("^(\\w+)\\W+(?>(\\w+)\\W+)*(\\w+)$", "now is the time for all good men to come to the aid of the party", e7);
pchar e8[5][9] =
{
{ "now is the time for all good men to come to the aid of the party" } ,
{ "now" },
{ "is", "for", "men", "to", "of" },
{ "the", "time", "all", "good", "to", "come", "the", "aid", "the" },
{ "party" },
};
test_captures("^(\\w+)\\W+(?>(\\w+)\\W+(?:(\\w+)\\W+){0,2})*(\\w+)$", "now is the time for all good men to come to the aid of the party", e8);
return 0;
}

View File

@ -88,6 +88,7 @@ flag_info flag_data[] = {
{ BOOST_RE_STR("match_continuous"), 16, match_continuous, 3 },
{ BOOST_RE_STR("match_partial"), 13, match_partial, 3 },
{ BOOST_RE_STR("match_nosubs"), 12, match_nosubs, 3 },
{ BOOST_RE_STR("match_single_line"), 17, match_single_line, 3 },
{ BOOST_RE_STR("format_all"), 10, format_all, 3 },
{ BOOST_RE_STR("format_sed"), 10, format_sed, 3 },

View File

@ -283,7 +283,7 @@ struct debug_iterator
debug_iterator(T c, T f, T l)
: cur(c), first(f), last(l) {}
debug_iterator() : cur(), first(), last() {}
debug_iterator(int = 0) : cur(), first(), last() {}
debug_iterator(const debug_iterator& x)
: cur(x.cur), first(x.first), last(x.last) {}
debug_iterator& operator=(const debug_iterator& x)

View File

@ -292,6 +292,22 @@ ab$ ab -1 -1
ab$ abxx -1 -1
ab$ ab\nzz 0 2
; line anchors, single line mode
- match_default normal match_single_line REG_NO_POSIX_TEST
^ab ab 0 2
^ab xxabxx -1 -1
^ab xx\nabzz -1 -1
ab$ ab 0 2
ab$ abxx -1 -1
ab$ ab\nzz -1 -1
- match_default match_not_bol match_not_eol normal REG_NO_POSIX_TEST match_single_line
^ab ab -1 -1
^ab xxabxx -1 -1
^ab xx\nabzz -1 -1
ab$ ab -1 -1
ab$ abxx -1 -1
ab$ ab\nzz -1 -1
; back references
- match_default normal REG_PERL
a(b)\2c !