added license info in copyright notice at the footer

[SVN r40867]
This commit is contained in:
Joel de Guzman
2007-11-07 03:23:31 +00:00
parent 39eb48c805
commit 15f764a95a
82 changed files with 3013 additions and 2625 deletions

View File

@ -1,13 +1,14 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Understanding Marked Sub-Expressions and Captures</title>
<title> Understanding Marked Sub-Expressions
and Captures</title>
<link rel="stylesheet" href="../../../../../doc/html/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot_2006-12-17_0120">
<meta name="generator" content="DocBook XSL Stylesheets V1.66.1">
<link rel="start" href="../index.html" title="Boost.Regex">
<link rel="up" href="../index.html" title="Boost.Regex">
<link rel="prev" href="unicode.html" title="Unicode and Boost.Regex">
<link rel="next" href="partial_matches.html" title="Partial Matches">
<link rel="prev" href="unicode.html" title=" Unicode and Boost.Regex">
<link rel="next" href="partial_matches.html" title=" Partial Matches">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
@ -24,9 +25,9 @@
</div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="boost_regex.captures"></a><a href="captures.html" title="Understanding Marked Sub-Expressions and Captures"> Understanding Marked Sub-Expressions
and Captures</a>
</h2></div></div></div>
<a name="boost_regex.captures"></a><a href="captures.html" title=" Understanding Marked Sub-Expressions
and Captures"> Understanding Marked Sub-Expressions
and Captures</a></h2></div></div></div>
<p>
Captures are the iterator ranges that are "captured" by marked sub-expressions
as a regular expression gets matched. Each marked sub-expression can result
@ -34,12 +35,12 @@
how captures and marked sub-expressions in Boost.Regex are represented and
accessed.
</p>
<a name="boost_regex.captures.marked_sub_expressions"></a><h5>
<a name="id492811"></a>
<a name="boost_regex.captures.marked_sub_expressions"></a><h4>
<a name="id459027"></a>
<a href="captures.html#boost_regex.captures.marked_sub_expressions">Marked sub-expressions</a>
</h5>
</h4>
<p>
Every time a Perl regular expression contains a parenthesis group <code class="computeroutput"><span class="special">()</span></code>, it spits out an extra field, known as a
Every time a Perl regular expression contains a parenthesis group <tt class="computeroutput"><span class="special">()</span></tt>, it spits out an extra field, known as a
marked sub-expression, for example the expression:
</p>
<pre class="programlisting">(\w+)\W+(\w+)</pre>
@ -47,7 +48,7 @@
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 $'. So if the above expression is searched
for within <code class="computeroutput"><span class="string">"@abc def--"</span></code>,
for within <tt class="computeroutput"><span class="string">"@abc def--"</span></tt>,
then we obtain:
</p>
<div class="informaltable"><table class="table">
@ -131,8 +132,8 @@
</tbody>
</table></div>
<p>
In Boost.Regex all these are accessible via the <a href="ref/match_results.html" title="match_results"><code class="computeroutput"><span class="identifier">match_results</span></code></a> class that gets filled
in when calling one of the regular expression matching algorithms ( <a href="ref/regex_search.html" title="regex_search"><code class="computeroutput"><span class="identifier">regex_search</span></code></a>, <a href="ref/regex_match.html" title="regex_match"><code class="computeroutput"><span class="identifier">regex_match</span></code></a>, or <a href="ref/regex_iterator.html" title="regex_iterator"><code class="computeroutput"><span class="identifier">regex_iterator</span></code></a>). So given:
In Boost.Regex all these are accessible via the <a href="ref/match_results.html" title=" match_results"><tt class="computeroutput"><span class="identifier">match_results</span></tt></a> class that gets filled
in when calling one of the regular expression matching algorithms ( <a href="ref/regex_search.html" title=" regex_search"><tt class="computeroutput"><span class="identifier">regex_search</span></tt></a>, <a href="ref/regex_match.html" title=" regex_match"><tt class="computeroutput"><span class="identifier">regex_match</span></tt></a>, or <a href="ref/regex_iterator.html" title=" regex_iterator"><tt class="computeroutput"><span class="identifier">regex_iterator</span></tt></a>). So given:
</p>
<pre class="programlisting">
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">match_results</span><span class="special">&lt;</span><span class="identifier">IteratorType</span><span class="special">&gt;</span> <span class="identifier">m</span><span class="special">;</span>
@ -166,7 +167,7 @@
</td>
<td>
<p>
<code class="computeroutput"><span class="identifier">m</span><span class="special">.</span><span class="identifier">prefix</span><span class="special">()</span></code>
<tt class="computeroutput"><span class="identifier">m</span><span class="special">.</span><span class="identifier">prefix</span><span class="special">()</span></tt>
</p>
</td>
</tr>
@ -178,7 +179,7 @@
</td>
<td>
<p>
<code class="computeroutput"><span class="identifier">m</span><span class="special">[</span><span class="number">0</span><span class="special">]</span></code>
<tt class="computeroutput"><span class="identifier">m</span><span class="special">[</span><span class="number">0</span><span class="special">]</span></tt>
</p>
</td>
</tr>
@ -190,7 +191,7 @@
</td>
<td>
<p>
<code class="computeroutput"><span class="identifier">m</span><span class="special">[</span><span class="identifier">n</span><span class="special">]</span></code>
<tt class="computeroutput"><span class="identifier">m</span><span class="special">[</span><span class="identifier">n</span><span class="special">]</span></tt>
</p>
</td>
</tr>
@ -202,26 +203,26 @@
</td>
<td>
<p>
<code class="computeroutput"><span class="identifier">m</span><span class="special">.</span><span class="identifier">suffix</span><span class="special">()</span></code>
<tt class="computeroutput"><span class="identifier">m</span><span class="special">.</span><span class="identifier">suffix</span><span class="special">()</span></tt>
</p>
</td>
</tr>
</tbody>
</table></div>
<p>
In Boost.Regex each sub-expression match is represented by a <a href="ref/sub_match.html" title="sub_match"><code class="computeroutput"><span class="identifier">sub_match</span></code></a> object, this is basically
In Boost.Regex each sub-expression match is represented by a <a href="ref/sub_match.html" title=" sub_match"><tt class="computeroutput"><span class="identifier">sub_match</span></tt></a> object, this is basically
just a pair of iterators denoting the start and end position of the sub-expression
match, but there are some additional operators provided so that objects of
type <a href="ref/sub_match.html" title="sub_match"><code class="computeroutput"><span class="identifier">sub_match</span></code></a>
behave a lot like a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_string</span></code>: for example they are implicitly
convertible to a <code class="computeroutput"><span class="identifier">basic_string</span></code>,
type <a href="ref/sub_match.html" title=" sub_match"><tt class="computeroutput"><span class="identifier">sub_match</span></tt></a>
behave a lot like a <tt class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_string</span></tt>: for example they are implicitly
convertible to a <tt class="computeroutput"><span class="identifier">basic_string</span></tt>,
they can be compared to a string, added to a string, or streamed out to an
output stream.
</p>
<a name="boost_regex.captures.unmatched_sub_expressions"></a><h5>
<a name="id493435"></a>
<a name="boost_regex.captures.unmatched_sub_expressions"></a><h4>
<a name="id459648"></a>
<a href="captures.html#boost_regex.captures.unmatched_sub_expressions">Unmatched Sub-Expressions</a>
</h5>
</h4>
<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:
@ -229,12 +230,12 @@
<pre class="programlisting">(abc)|(def)</pre>
<p>
can match either $1 or $2, but never both at the same time. In Boost.Regex
you can determine which sub-expressions matched by accessing the <code class="computeroutput"><span class="identifier">sub_match</span><span class="special">::</span><span class="identifier">matched</span></code> data member.
you can determine which sub-expressions matched by accessing the <tt class="computeroutput"><span class="identifier">sub_match</span><span class="special">::</span><span class="identifier">matched</span></tt> data member.
</p>
<a name="boost_regex.captures.repeated_captures"></a><h5>
<a name="id493497"></a>
<a name="boost_regex.captures.repeated_captures"></a><h4>
<a name="id459714"></a>
<a href="captures.html#boost_regex.captures.repeated_captures">Repeated Captures</a>
</h5>
</h4>
<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
@ -251,7 +252,7 @@
</p>
<p>
However, Boost.Regex has an experimental feature that allows all the capture
information to be retained - this is accessed either via the <code class="computeroutput"><span class="identifier">match_results</span><span class="special">::</span><span class="identifier">captures</span></code> member function or the <code class="computeroutput"><span class="identifier">sub_match</span><span class="special">::</span><span class="identifier">captures</span></code> member function. These functions
information to be retained - this is accessed either via the <tt class="computeroutput"><span class="identifier">match_results</span><span class="special">::</span><span class="identifier">captures</span></tt> member function or the <tt class="computeroutput"><span class="identifier">sub_match</span><span class="special">::</span><span class="identifier">captures</span></tt> member function. These functions
return a container that contains a sequence of all the captures obtained during
the regular expression matching. The following example program shows how this
information may be used:
@ -371,7 +372,10 @@ Text: "now is the time for all good men to come to the aid of the party"
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><small>Copyright <20> 2007 John Maddock</small></td>
<td align="right"><div class="copyright-footer"><small>Copyright <20> 2007 John Maddock<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p></small></div></td>
</tr></table>
<hr>
<div class="spirit-nav">