Finished checking docs, code should now be ready for release...

[SVN r18428]
This commit is contained in:
John Maddock
2003-05-17 11:19:02 +00:00
parent 460d2a97a9
commit 74c7ea377d
79 changed files with 12002 additions and 9727 deletions

View File

@ -65,7 +65,7 @@ bad_expression(const string& what_arg);
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
<p><i><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
@ -79,3 +79,4 @@ bad_expression(const string&amp; what_arg);
for any purpose. It is provided "as is" without express or implied warranty.</i></p>
</body>
</html>

File diff suppressed because it is too large Load Diff

View File

@ -4,18 +4,16 @@
<title>Boost.Regex: Configuration and setup</title>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content=
"text/html; charset=iso-8859-1" >
"text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<p></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>
"C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<td width="353">
<h1 align="center">Boost.Regex</h1>
@ -24,7 +22,7 @@ border="0">
</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>
"Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</tr>
</table>
@ -37,13 +35,13 @@ border="0">
<h2>Contents</h2>
<dl class="index">
<dt><a href="#compiler">Compiler setup</a>
<dt><a href="#compiler">Compiler setup</a></dt>
<dt><a href="#locale">Locale and traits class selection</a>
<dt><a href="#locale">Locale and traits class selection</a></dt>
<dt><a href="#linkage">Linkage Options</a>
<dt><a href="#linkage">Linkage Options</a></dt>
<dt><a href="#algorithm">Algorithm Selection</a>
<dt><a href="#algorithm">Algorithm Selection</a></dt>
<dt><a href="#tuning">Algorithm Tuning</a></dt>
</dl>
@ -60,8 +58,6 @@ particularly obscure compiler or platform) then <a href="../../config/index.html
<p>The following macros (see <a href="../../../boost/regex/user.hpp">user.hpp</a>) control how
boost.regex interacts with the user's locale:</p>
<p></p>
<table id="Table2" cellspacing="1" cellpadding="1" width="100%"
border="1">
<tr>
@ -93,16 +89,14 @@ BOOST_REGEX_USE_CPP_LOCALE is set).</td>
<h3><a name="linkage"></a>Linkage Options</h3>
<p></p>
<table id="Table3" cellspacing="1" cellpadding="1" width="100%"
border="1">
<tr>
<td>BOOST_REGEX_DYN_LINK</td>
<td>For Microsoft and Borland C++ builds, this tells
boost.regex that it should link to the dll build of the boost.regex.&nbsp; By default
boost.regex will link to its static library build, even if the dynamic C runtime library
is in use.</td>
<td>For Microsoft and Borland C++ builds, this tells boost.regex
that it should link to the dll build of the boost.regex.&nbsp; By
default boost.regex will link to its static library build, even if
the dynamic C runtime library is in use.</td>
</tr>
<tr>
@ -119,8 +113,6 @@ to.</td>
<h3><a name="algorithm"></a>Algorithm Selection</h3>
<p></p>
<table id="Table4" cellspacing="1" cellpadding="1" width="100%"
border="1">
<tr>
@ -157,8 +149,6 @@ expression.&nbsp; This is the default on non-Win32 platforms.</td>
<p>The following option applies only if BOOST_REGEX_RECURSIVE is
set.</p>
<p></p>
<table id="Table6" cellspacing="1" cellpadding="1" width="100%"
border="1">
<tr>
@ -175,8 +165,6 @@ are supported, and can be used to safely trap stack overflow.</td>
<p>The following options apply only if BOOST_REGEX_NON_RECURSIVE is
set.</p>
<p></p>
<table id="Table5" cellspacing="1" cellpadding="1" width="100%"
border="1">
<tr>
@ -220,16 +208,13 @@ order.</td>
<br>
<p></p>
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->11
April 2003
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
<p><i><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John
Maddock</a>&nbsp;1998-
<p><i>&copy; Copyright <a href="mailto:jm@regex.fsnet.co.uk">John
Maddock</a>&nbsp;1998-
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
@ -243,3 +228,5 @@ software for any purpose. It is provided "as is" without express or
implied warranty.</i></p>
</body>
</html>

View File

@ -90,8 +90,7 @@ papers available from their respective web sites.</p>
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->11
April 2003
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
<p><i><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John

View File

@ -81,8 +81,7 @@
<P></P>
<HR>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->11
April 2003
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
<p><i><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John
@ -97,3 +96,4 @@ Maddock</a>&nbsp;1998-
for any purpose. It is provided "as is" without express or implied warranty.</i></p>
</body>
</html>

View File

@ -1,118 +1,162 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: FAQ</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">FAQ</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>
<FONT color="#ff0000"><FONT color="#ff0000">
<P><FONT color="#ff0000">&nbsp;Q. Why can't I use the "convenience" versions of
regex_match / regex_search / regex_grep / regex_format / regex_merge?</FONT>
</P>
</FONT></FONT>
<P>A. These versions may or may not be available depending upon the capabilities
of your compiler, the rules determining the format of these functions are quite
complex - and only the versions visible to a standard compliant compiler are
given in the help. To find out what your compiler supports, run
&lt;boost/regex.hpp&gt; through your C++ pre-processor, and search the output
file for the function that you are interested in.<FONT color="#ff0000"><FONT color="#ff0000">
</P>
<P>Q. I can't get regex++ to work with escape characters, what's going on?</FONT>
</P>
</FONT>
<P>A. If you embed regular expressions in C++ code, then remember that escape
characters are processed twice: once by the C++ compiler, and once by the
regex++ expression compiler, so to pass the regular expression \d+ to regex++,
you need to embed "\\d+" in your code. Likewise to match a literal backslash
you will need to embed "\\\\" in your code.<FONT color="#ff0000">
</P>
<P>Q. Why does using parenthesis in a POSIX regular expression change the result
of a match?</FONT></P>
<P>For POSIX (extended and basic) regular expressions, but not for perl regexes,
parentheses don't only mark; they determine what the best match is as well.
When the expression is compiled as a POSIX basic or extended regex then
Boost.regex follows the POSIX standard leftmost longest rule for determining
what matched. So if there is more than one possible match after considering the
whole expression, it looks next at the first sub-expression and then the second
sub-expression and so on. So...</P>
<PRE>"(0*)([0-9]*)" against "00123" would produce
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<title>Boost.Regex: FAQ</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></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">FAQ</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>
<br>
<br>
<hr>
<font color="#ff0000"><font color="#ff0000"></font></font>
<p><font color="#ff0000"><font color="#ff0000"><font color=
"#ff0000">&nbsp;Q. Why can't I use the "convenience" versions of
regex_match / regex_search / regex_grep / regex_format /
regex_merge?</font></font></font></p>
<p>A. These versions may or may not be available depending upon the
capabilities of your compiler, the rules determining the format of
these functions are quite complex - and only the versions visible
to a standard compliant compiler are given in the help. To find out
what your compiler supports, run &lt;boost/regex.hpp&gt; through
your C++ pre-processor, and search the output file for the function
that you are interested in.<font color="#ff0000"><font color=
"#ff0000"></font></font></p>
<p><font color="#ff0000"><font color="#ff0000">Q. I can't get
regex++ to work with escape characters, what's going
on?</font></font></p>
<p>A. If you embed regular expressions in C++ code, then remember
that escape characters are processed twice: once by the C++
compiler, and once by the regex++ expression compiler, so to pass
the regular expression \d+ to regex++, you need to embed "\\d+" in
your code. Likewise to match a literal backslash you will need to
embed "\\\\" in your code. <font color="#ff0000"></font></p>
<p><font color="#ff0000">Q. Why does using parenthesis in a POSIX
regular expression change the result of a match?</font></p>
<p>For POSIX (extended and basic) regular expressions, but not for
perl regexes, parentheses don't only mark; they determine what the
best match is as well. When the expression is compiled as a POSIX
basic or extended regex then Boost.regex follows the POSIX standard
leftmost longest rule for determining what matched. So if there is
more than one possible match after considering the whole
expression, it looks next at the first sub-expression and then the
second sub-expression and so on. So...</p>
<pre>
"(0*)([0-9]*)" against "00123" would produce
$1 = "00"
$2 = "123"</PRE>
<P>where as</P>
<PRE>"0*([0-9)*" against "00123" would produce
$1 = "00123"</PRE>
<P>If you think about it, had $1 only matched the "123", this would be "less good"
than the match "00123" which is both further to the left and longer. If you
want $1 to match only the "123" part, then you need to use something like:</P>
<PRE>"0*([1-9][0-9]*)"</PRE>
<P>as the expression.</P>
<P><FONT color="#ff0000">Q. Why don't character ranges work properly (POSIX mode
only)?</FONT>
<BR>
A. The POSIX standard specifies that character range expressions are locale
sensitive - so for example the expression [A-Z] will match any collating
element that collates between 'A' and 'Z'. That means that for most locales
other than "C" or "POSIX", [A-Z] would match the single character 't' for
example, which is not what most people expect - or at least not what most
people have come to expect from regular expression engines. For this reason,
the default behaviour of boost.regex (perl mode) is to turn locale sensitive
collation off by not setting the regex_constants::collate compile time flag.
However if you set a non-default compile time flag - for example
regex_constants::extended or regex_constants::basic, then locale dependent
collation will be enabled, this also applies to the POSIX API functions which
use either regex_constants::extended or regex_constants::basic internally. <I>[Note
- when regex_constants::nocollate in effect, the library behaves "as if" the
LC_COLLATE locale category were always "C", regardless of what its actually set
to - end note</I>].
</P>
<P><FONT color="#ff0000">Q. Why are there no throw specifications on any of the
functions? What exceptions can the library throw?</FONT>
</P>
<P>
A. Not all compilers support (or honor) throw specifications, others support
them but with reduced efficiency. Throw specifications may be added at a later
date as compilers begin to handle this better. The library should throw only
three types of exception: boost::bad_expression can be thrown by basic_regex
when compiling a regular expression, std::runtime_error can be thrown when a
call to basic_regex::imbue tries to open a message catalogue that doesn't
exist, or when a call to regex_search or regex_match results in an
"everlasting" search,&nbsp;or when a call to RegEx::GrepFiles or
RegEx::FindFiles tries to open a file that cannot be opened, finally
std::bad_alloc can be thrown by just about any of the functions in this
library.
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
$2 = "123"
</pre>
<p>where as</p>
<pre>
"0*([0-9)*" against "00123" would produce
$1 = "00123"
</pre>
<p>If you think about it, had $1 only matched the "123", this would
be "less good" than the match "00123" which is both further to the
left and longer. If you want $1 to match only the "123" part, then
you need to use something like:</p>
<pre>
"0*([1-9][0-9]*)"
</pre>
<p>as the expression.</p>
<p><font color="#ff0000">Q. Why don't character ranges work
properly (POSIX mode only)?</font><br>
A. The POSIX standard specifies that character range expressions
are locale sensitive - so for example the expression [A-Z] will
match any collating element that collates between 'A' and 'Z'. That
means that for most locales other than "C" or "POSIX", [A-Z] would
match the single character 't' for example, which is not what most
people expect - or at least not what most people have come to
expect from regular expression engines. For this reason, the
default behaviour of boost.regex (perl mode) is to turn locale
sensitive collation off by not setting the regex_constants::collate
compile time flag. However if you set a non-default compile time
flag - for example regex_constants::extended or
regex_constants::basic, then locale dependent collation will be
enabled, this also applies to the POSIX API functions which use
either regex_constants::extended or regex_constants::basic
internally. <i>[Note - when regex_constants::nocollate in effect,
the library behaves "as if" the LC_COLLATE locale category were
always "C", regardless of what its actually set to - end
note</i>].</p>
<p><font color="#ff0000">Q. Why are there no throw specifications
on any of the functions? What exceptions can the library
throw?</font></p>
<p>A. Not all compilers support (or honor) throw specifications,
others support them but with reduced efficiency. Throw
specifications may be added at a later date as compilers begin to
handle this better. The library should throw only three types of
exception: boost::bad_expression can be thrown by basic_regex when
compiling a regular expression, std::runtime_error can be thrown
when a call to basic_regex::imbue tries to open a message catalogue
that doesn't exist, or when a call to regex_search or regex_match
results in an "everlasting" search,&nbsp;or when a call to
RegEx::GrepFiles or RegEx::FindFiles tries to open a file that
cannot be opened, finally std::bad_alloc can be thrown by just
about any of the functions in this library.</p>
<p></p>
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
<p><i>&copy; Copyright <a href="mailto:jm@regex.fsnet.co.uk">John
Maddock</a>&nbsp;1998-
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
<p align="left"><i>Permission to use, copy, modify, distribute and
sell this software and its documentation for any purpose is hereby
granted without fee, provided that the above copyright notice
appear in all copies and that both that copyright notice and this
permission notice appear in supporting documentation. Dr John
Maddock makes no representations about the suitability of this
software for any purpose. It is provided "as is" without express or
implied warranty.</i></p>
</body>
</html>

View File

@ -1,217 +1,272 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Format String Syntax</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">Format String Syntax</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>
<P>Format strings are used by the algorithm <A href="template_class_ref.htm#reg_merge">
regex_merge</A>&nbsp;and by <A href="match_results.html">match_results::format</A>,
and are used to transform one string into another.
</P>
<P>There are three kind of format string: sed, Perl and extended, the extended
syntax is a superset of the others so this is covered first.
</P>
<P><B><I>Extended format syntax</I></B>
</P>
<P>In format strings, all characters are treated as literals except: ()$\?:
</P>
<P>To use any of these as literals you must prefix them with the escape character
\
</P>
<P>The following special sequences are recognized:&nbsp;<BR>
&nbsp;
<BR>
<I>Grouping:</I>
</P>
<P>Use the parenthesis characters ( and ) to group sub-expressions within the
format string, use \( and \) to represent literal '(' and ')'.&nbsp;<BR>
&nbsp;
<BR>
<I>Sub-expression expansions:</I>
</P>
<P>The following Perl like expressions expand to a particular matched
sub-expression:
<BR>
&nbsp;
</P>
<P>
<TABLE id="Table2" cellSpacing="0" cellPadding="7" width="100%" border="0">
<TR>
<TD vAlign="top" width="8%">&nbsp;</TD>
<TD vAlign="top" width="40%">$`</TD>
<TD vAlign="top" width="43%">Expands to all the text from the end of the previous
match to the start of the current match, if there was no previous match in the
current operation, then everything from the start of the input string to the
start of the match.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="8%">&nbsp;</TD>
<TD vAlign="top" width="40%">$'</TD>
<TD vAlign="top" width="43%">Expands to all the text from the end of the match to
the end of the input string.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="8%">&nbsp;</TD>
<TD vAlign="top" width="40%">$&amp;</TD>
<TD vAlign="top" width="43%">Expands to all of the current match.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="8%">&nbsp;</TD>
<TD vAlign="top" width="40%">$0</TD>
<TD vAlign="top" width="43%">Expands to all of the current match.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="8%">&nbsp;</TD>
<TD vAlign="top" width="40%">$N</TD>
<TD vAlign="top" width="43%">Expands to the text that matched sub-expression <I>N</I>.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
</TABLE>
</P>
<P><I>Conditional expressions:</I>
</P>
<P>Conditional expressions allow two different format strings to be selected
dependent upon whether a sub-expression participated in the match or not:
</P>
<P>?Ntrue_expression:false_expression
</P>
<P>Executes true_expression if sub-expression <I>N</I> participated in the match,
otherwise executes false_expression.
</P>
<P>Example: suppose we search for "(while)|(for)" then the format string
"?1WHILE:FOR" would output what matched, but in upper case.&nbsp;<BR>
&nbsp;
<BR>
<I>Escape sequences:</I>
</P>
<P>The following escape sequences are also allowed:
<BR>
</P>
<P>
<TABLE id="Table3" cellSpacing="0" cellPadding="7" width="100%" border="0">
<TR>
<TD vAlign="top" width="8%">&nbsp;</TD>
<TD vAlign="top" width="40%">\a</TD>
<TD vAlign="top" width="43%">The bell character.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="8%">&nbsp;</TD>
<TD vAlign="top" width="40%">\f</TD>
<TD vAlign="top" width="43%">The form feed character.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="8%">&nbsp;</TD>
<TD vAlign="top" width="40%">\n</TD>
<TD vAlign="top" width="43%">The newline character.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="8%">&nbsp;</TD>
<TD vAlign="top" width="40%">\r</TD>
<TD vAlign="top" width="43%">The carriage return character.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="8%">&nbsp;</TD>
<TD vAlign="top" width="40%">\t</TD>
<TD vAlign="top" width="43%">The tab character.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="8%">&nbsp;</TD>
<TD vAlign="top" width="40%">\v</TD>
<TD vAlign="top" width="43%">A vertical tab character.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="8%">&nbsp;</TD>
<TD vAlign="top" width="40%">\x</TD>
<TD vAlign="top" width="43%">A hexadecimal character - for example \x0D.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="8%">&nbsp;</TD>
<TD vAlign="top" width="40%">\x{}</TD>
<TD vAlign="top" width="43%">A possible Unicode hexadecimal character - for
example \x{1A0}</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="8%">&nbsp;</TD>
<TD vAlign="top" width="40%">\cx</TD>
<TD vAlign="top" width="43%">The ASCII escape character x, for example \c@ is
equivalent to escape-@.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="8%">&nbsp;</TD>
<TD vAlign="top" width="40%">\e</TD>
<TD vAlign="top" width="43%">The ASCII escape character.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="8%">&nbsp;</TD>
<TD vAlign="top" width="40%">\dd</TD>
<TD vAlign="top" width="43%">An octal character constant, for example \10.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
</TABLE>
</P>
<P><B><I>Perl format strings</I></B>
</P>
<P>Perl format strings are the same as the default syntax except that the
characters ()?: have no special meaning.
</P>
<P><B><I>Sed format strings</I></B>
</P>
<P>Sed format strings use only the characters \ and &amp; as special characters.
</P>
<P>\n where n is a digit, is expanded to the nth sub-expression.
</P>
<P>&amp; is expanded to the whole of the match (equivalent to \0).
</P>
<P>
Other escape sequences are expanded as per the default syntax.
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<title>Boost.Regex: Format String Syntax</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></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">Format String Syntax</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>
<br>
<br>
<hr>
<p>Format strings are used by the algorithm <a href="template_class_ref.htm#reg_merge">regex_merge</a>&nbsp;and by <a
href="match_results.html">match_results::format</a>, and are used
to transform one string into another.</p>
<p>There are three kind of format string: sed, Perl and extended,
the extended syntax is a superset of the others so this is covered
first.</p>
<p><b><i>Extended format syntax</i></b></p>
<p>In format strings, all characters are treated as literals
except: ()$\?:</p>
<p>To use any of these as literals you must prefix them with the
escape character \</p>
<p>The following special sequences are recognized:&nbsp;<br>
&nbsp;<br>
<i>Grouping:</i></p>
<p>Use the parenthesis characters ( and ) to group sub-expressions
within the format string, use \( and \) to represent literal '('
and ')'.&nbsp;<br>
&nbsp;<br>
<i>Sub-expression expansions:</i></p>
<p>The following Perl like expressions expand to a particular
matched sub-expression:<br>
&nbsp;</p>
<p></p>
<table id="Table2" cellspacing="0" cellpadding="7" width="100%"
border="0">
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">$`</td>
<td valign="top" width="43%">Expands to all the text from the end
of the previous match to the start of the current match, if there
was no previous match in the current operation, then everything
from the start of the input string to the start of the match.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">$'</td>
<td valign="top" width="43%">Expands to all the text from the end
of the match to the end of the input string.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">$&amp;</td>
<td valign="top" width="43%">Expands to all of the current
match.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">$0</td>
<td valign="top" width="43%">Expands to all of the current
match.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">$N</td>
<td valign="top" width="43%">Expands to the text that matched
sub-expression <i>N</i>.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
</table>
<br>
<br>
<p><i>Conditional expressions:</i></p>
<p>Conditional expressions allow two different format strings to be
selected dependent upon whether a sub-expression participated in
the match or not:</p>
<p>?Ntrue_expression:false_expression</p>
<p>Executes true_expression if sub-expression <i>N</i> participated
in the match, otherwise executes false_expression.</p>
<p>Example: suppose we search for "(while)|(for)" then the format
string "?1WHILE:FOR" would output what matched, but in upper
case.&nbsp;<br>
&nbsp;<br>
<i>Escape sequences:</i></p>
<p>The following escape sequences are also allowed:<br>
</p>
<p></p>
<table id="Table3" cellspacing="0" cellpadding="7" width="100%"
border="0">
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">\a</td>
<td valign="top" width="43%">The bell character.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">\f</td>
<td valign="top" width="43%">The form feed character.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">\n</td>
<td valign="top" width="43%">The newline character.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">\r</td>
<td valign="top" width="43%">The carriage return character.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">\t</td>
<td valign="top" width="43%">The tab character.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">\v</td>
<td valign="top" width="43%">A vertical tab character.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">\x</td>
<td valign="top" width="43%">A hexadecimal character - for example
\x0D.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">\x{}</td>
<td valign="top" width="43%">A possible Unicode hexadecimal
character - for example \x{1A0}</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">\cx</td>
<td valign="top" width="43%">The ASCII escape character x, for
example \c@ is equivalent to escape-@.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">\e</td>
<td valign="top" width="43%">The ASCII escape character.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">\dd</td>
<td valign="top" width="43%">An octal character constant, for
example \10.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
</table>
<br>
<br>
<p><b><i>Perl format strings</i></b></p>
<p>Perl format strings are the same as the default syntax except
that the characters ()?: have no special meaning.</p>
<p><b><i>Sed format strings</i></b></p>
<p>Sed format strings use only the characters \ and &amp; as
special characters.</p>
<p>\n where n is a digit, is expanded to the nth
sub-expression.</p>
<p>&amp; is expanded to the whole of the match (equivalent to
\0).</p>
<p>Other escape sequences are expanded as per the default
syntax.</p>
<p></p>
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
<p><i>&copy; Copyright <a href="mailto:jm@regex.fsnet.co.uk">John
Maddock</a>&nbsp;1998-
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
<p align="left"><i>Permission to use, copy, modify, distribute and
sell this software and its documentation for any purpose is hereby
granted without fee, provided that the above copyright notice
appear in all copies and that both that copyright notice and this
permission notice appear in supporting documentation. Dr John
Maddock makes no representations about the suitability of this
software for any purpose. It is provided "as is" without express or
implied warranty.</i></p>
</body>
</html>

View File

@ -37,7 +37,7 @@
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
@ -49,3 +49,4 @@
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -43,7 +43,7 @@
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
@ -55,3 +55,4 @@
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -30,7 +30,7 @@
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
@ -42,3 +42,4 @@
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -222,7 +222,7 @@
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
@ -234,3 +234,4 @@
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -159,7 +159,7 @@ std::string human_readable_card_number(<B>const</B> std::string s)
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
@ -173,3 +173,4 @@ std::string human_readable_card_number(<B>const</B> std::string s)
</html>

File diff suppressed because it is too large Load Diff

View File

@ -1,34 +1,47 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: match_flag_type</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">match_flag_type</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>
<H3>Synopsis</H3>
<P>The type <CODE>match_flag_type</CODE> is an implementation defined bitmask type
(17.3.2.1.2) that controls how a regular expression is matched against a
character sequence.</P>
<PRE>namespace std{ namespace regex_constants{
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<title>Boost.Regex: match_flag_type</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></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">match_flag_type</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>
<br>
<br>
<hr>
<h3>Synopsis</h3>
<p>The type <code>match_flag_type</code> is an implementation
defined bitmask type (17.3.2.1.2) that controls how a regular
expression is matched against a character sequence.</p>
<pre>
namespace std{ namespace regex_constants{
typedef bitmask_type match_flag_type;
@ -55,212 +68,263 @@ static const match_flag_type format_first_only;
static const match_flag_type format_all;
} // namespace regex_constants
} // namespace std</PRE>
<H3>Description</H3>
<P>The type <CODE>match_flag_type</CODE> is an implementation defined bitmask type
(17.3.2.1.2). When matching a regular expression against a sequence of
characters [first, last) then setting its elements has the effects listed in
the table below:</P>
<P>
<TABLE id="Table2" cellSpacing="1" cellPadding="7" width="100%" border="0">
<TR>
<TD vAlign="top" width="50%">
<P>Element</P>
</TD>
<TD vAlign="top" width="50%">
<P>Effect if set</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>match_default</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that matching of regular expressions proceeds without any
modification of the normal rules used in ECMA-262, ECMAScript Language
Specification, Chapter 15 part 10, RegExp (Regular Expression) Objects (FWD.1)</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">match_not_bob</TD>
<TD vAlign="top" width="50%">Specifies that the expression "\A" should not match
against the sub-sequence [first,first).</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">match_not_eob</TD>
<TD vAlign="top" width="50%">Specifies that the expressions "\z" and
"\Z"&nbsp;should not match against the sub-sequence [last,last).</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>match_not_bol</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that the expression "^" should not be matched against the
sub-sequence [first,first).</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>match_not_eol</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that the expression "$" should not be matched against the
sub-sequence [last,last).</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>match_not_bow</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that the expression "\b" should not be matched against the
sub-sequence [first,first).</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>match_not_eow</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that the expression "\b" should not be matched against the
sub-sequence [last,last).</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>match_any</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that if more than one match is possible then any match is an
acceptable result.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>match_not_null</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that the expression can not be matched against an empty sequence.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>match_continuous</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that the expression must match a sub-sequence that begins at <I>first</I>.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>match_partial</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that if no match can be found, then it is acceptable to return a
match [from, last) where from!=last, if there exists some sequence of
characters [from,to) of which [from,last) is a prefix, and which would result
in a full match.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>match_prev_avail</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that <CODE>--first</CODE> is a valid iterator position, when this
flag is set then the flags <CODE>match_not_bol</CODE> and <CODE>match_not_bow</CODE>
are ignored by the regular expression algorithms (RE.7) and iterators (RE.8).</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">match_not_dot_newline</TD>
<TD vAlign="top" width="50%">Specifies that the expression "." does not match a
newline character.</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">match_not_dot_null</TD>
<TD vAlign="top" width="50%">Specified that the expression "." does not match a
character null '\0'.</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>format_default</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that when a regular expression match is to be replaced by a new
string, that the new string is constructed using the rules used by the
ECMAScript replace function in ECMA-262, ECMAScript Language Specification,
Chapter 15 part 5.4.11 String.prototype.replace. (FWD.1). In addition during
search and replace operations then all non-overlapping occurrences of the
regular expression are located and replaced, and sections of the input that did
not match the expression, are copied unchanged to the output string.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>format_sed</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that when a regular expression match is to be replaced by a new
string, that the new string is constructed using the rules used by the Unix sed
utility in IEEE Std 1003.1-2001, Portable Operating SystemInterface (POSIX ),
Shells and Utilities..</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>format_perl</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that when a regular expression match is to be replaced by a new
string, that the new string is constructed using an implementation defined
superset of the rules used by the ECMAScript replace function in ECMA-262,
ECMAScript Language Specification, Chapter 15 part 5.4.11
String.prototype.replace (FWD.1).</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%" height="32">format_all</TD>
<TD vAlign="top" width="50%" height="32">Specifies that all syntax extensions are
enabled, including conditional (?ddexpression1:expression2) replacements.</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>format_no_copy</P>
</TD>
<TD vAlign="top" width="50%">
<P>When specified during a search and replace operation, then sections of the
character container sequence being searched that do match the regular
expression, are not copied to the output string.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>format_first_only</P>
</TD>
<TD vAlign="top" width="50%">
<P>When specified during a search and replace operation, then only the first
occurrence of the regular expression is replaced.</P>
</TD>
</TR>
</TABLE>
</P>
<P>
<HR>
</P>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
} // namespace std
</pre>
<h3>Description</h3>
<p>The type <code>match_flag_type</code> is an implementation
defined bitmask type (17.3.2.1.2). When matching a regular
expression against a sequence of characters [first, last) then
setting its elements has the effects listed in the table below:</p>
<p></p>
<table id="Table2" cellspacing="1" cellpadding="7" width="100%"
border="0">
<tr>
<td valign="top" width="50%">
<p>Element</p>
</td>
<td valign="top" width="50%">
<p>Effect if set</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>match_default</p>
</td>
<td valign="top" width="50%">
<p>Specifies that matching of regular expressions proceeds without
any modification of the normal rules used in ECMA-262, ECMAScript
Language Specification, Chapter 15 part 10, RegExp (Regular
Expression) Objects (FWD.1)</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">match_not_bob</td>
<td valign="top" width="50%">Specifies that the expression "\A"
should not match against the sub-sequence [first,first).</td>
</tr>
<tr>
<td valign="top" width="50%">match_not_eob</td>
<td valign="top" width="50%">Specifies that the expressions "\z"
and "\Z"&nbsp;should not match against the sub-sequence
[last,last).</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>match_not_bol</p>
</td>
<td valign="top" width="50%">
<p>Specifies that the expression "^" should not be matched against
the sub-sequence [first,first).</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>match_not_eol</p>
</td>
<td valign="top" width="50%">
<p>Specifies that the expression "$" should not be matched against
the sub-sequence [last,last).</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>match_not_bow</p>
</td>
<td valign="top" width="50%">
<p>Specifies that the expression "\b" should not be matched against
the sub-sequence [first,first).</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>match_not_eow</p>
</td>
<td valign="top" width="50%">
<p>Specifies that the expression "\b" should not be matched against
the sub-sequence [last,last).</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>match_any</p>
</td>
<td valign="top" width="50%">
<p>Specifies that if more than one match is possible then any match
is an acceptable result.</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>match_not_null</p>
</td>
<td valign="top" width="50%">
<p>Specifies that the expression can not be matched against an
empty sequence.</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>match_continuous</p>
</td>
<td valign="top" width="50%">
<p>Specifies that the expression must match a sub-sequence that
begins at <i>first</i>.</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>match_partial</p>
</td>
<td valign="top" width="50%">
<p>Specifies that if no match can be found, then it is acceptable
to return a match [from, last) where from!=last, if there exists
some sequence of characters [from,to) of which [from,last) is a
prefix, and which would result in a full match.</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>match_prev_avail</p>
</td>
<td valign="top" width="50%">
<p>Specifies that <code>--first</code> is a valid iterator
position, when this flag is set then the flags <code>
match_not_bol</code> and <code>match_not_bow</code> are ignored by
the regular expression algorithms (RE.7) and iterators (RE.8).</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">match_not_dot_newline</td>
<td valign="top" width="50%">Specifies that the expression "." does
not match a newline character.</td>
</tr>
<tr>
<td valign="top" width="50%">match_not_dot_null</td>
<td valign="top" width="50%">Specified that the expression "." does
not match a character null '\0'.</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>format_default</p>
</td>
<td valign="top" width="50%">
<p>Specifies that when a regular expression match is to be replaced
by a new string, that the new string is constructed using the rules
used by the ECMAScript replace function in ECMA-262, ECMAScript
Language Specification, Chapter 15 part 5.4.11
String.prototype.replace. (FWD.1). In addition during search and
replace operations then all non-overlapping occurrences of the
regular expression are located and replaced, and sections of the
input that did not match the expression, are copied unchanged to
the output string.</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>format_sed</p>
</td>
<td valign="top" width="50%">
<p>Specifies that when a regular expression match is to be replaced
by a new string, that the new string is constructed using the rules
used by the Unix sed utility in IEEE Std 1003.1-2001, Portable
Operating SystemInterface (POSIX ), Shells and Utilities..</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>format_perl</p>
</td>
<td valign="top" width="50%">
<p>Specifies that when a regular expression match is to be replaced
by a new string, that the new string is constructed using an
implementation defined superset of the rules used by the ECMAScript
replace function in ECMA-262, ECMAScript Language Specification,
Chapter 15 part 5.4.11 String.prototype.replace (FWD.1).</p>
</td>
</tr>
<tr>
<td valign="top" width="50%" height="32">format_all</td>
<td valign="top" width="50%" height="32">Specifies that all syntax
extensions are enabled, including conditional
(?ddexpression1:expression2) replacements.</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>format_no_copy</p>
</td>
<td valign="top" width="50%">
<p>When specified during a search and replace operation, then
sections of the character container sequence being searched that do
match the regular expression, are not copied to the output
string.</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>format_first_only</p>
</td>
<td valign="top" width="50%">
<p>When specified during a search and replace operation, then only
the first occurrence of the regular expression is replaced.</p>
</td>
</tr>
</table>
<br>
<br>
<p></p>
<hr>
<br>
<br>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
<p><i>&copy; Copyright <a href="mailto:jm@regex.fsnet.co.uk">John
Maddock</a>&nbsp;1998-
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
<p align="left"><i>Permission to use, copy, modify, distribute and
sell this software and its documentation for any purpose is hereby
granted without fee, provided that the above copyright notice
appear in all copies and that both that copyright notice and this
permission notice appear in supporting documentation. Dr John
Maddock makes no representations about the suitability of this
software for any purpose. It is provided "as is" without express or
implied warranty.</i></p>
</body>
</html>

View File

@ -1,57 +1,78 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: class match_results</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">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>
</td>
</TR>
</TABLE>
</P>
<HR>
<H3>Contents</H3>
<DL class="index">
<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>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>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">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>The template class match_results conforms to the requirements of a Sequence, as
specified in (lib.sequence.reqmts), except that only operations defined for
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,
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<title>Boost.Regex: class match_results</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></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">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>
</td>
</tr>
</table>
<br>
<br>
<hr>
<h3>Contents</h3>
<dl class="index">
<dt><a href="#synopsis">Synopsis</a></dt>
<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>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>
<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">
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 specified in (lib.sequence.reqmts), except that only
operations defined for 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,
class Allocator = allocator&lt;sub_match&lt;BidirectionalIterator&gt; &gt;
class match_results;
@ -123,260 +144,368 @@ basic_ostream&lt;charT, traits&gt;&amp;
template &lt;class BidirectionalIterator, class Allocator&gt;
void swap(match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m1,
match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m2);</PRE>
<H3><A name="description"></A>Description</H3>
<H4>match_results constructors</H4>
<P>In all <CODE>match_results</CODE> constructors, a copy of the Allocator
argument is used for any memory allocation performed by the constructor or
member functions during the lifetime of the object.
</P>
<PRE>match_results(const Allocator&amp; a = Allocator());</PRE>
<B>
<P>
Effects:</B> Constructs an object of class match_results. The postconditions
of this function are indicated in the table:</P>
<P align="center">
<CENTER>
<TABLE id="Table2" cellSpacing="1" cellPadding="7" width="624" border="1">
<TBODY>
<TR>
<TD vAlign="top" width="50%"><B>
<P>
Element</B>
</P>
</TD>
<TD vAlign="top" width="50%"><B>
<P>
Value</B> </P></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>empty()</P>
</TD>
<TD vAlign="top" width="50%">
<P>true</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>size()</P>
</TD>
<TD vAlign="top" width="50%">
<P>0</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>str()</P>
</TD>
<TD vAlign="top" width="50%">
<P>basic_string&lt;charT&gt;()</P>
<P></P>
</TD>
</TR>
</TBODY></TD></TR></TABLE></CENTER>
<P></P>
<DIV></DIV>
<P>&nbsp;</P>
<PRE>match_results(const match_results&amp; m);</PRE>
<B>
<P>
Effects:</B> Constructs an object of class match_results, as a copy of
m.</P><PRE>match_results&amp; operator=(const match_results&amp; m);</PRE>
<B>
<P>
Effects:</B> Assigns m to *this. The postconditions of this function are
indicated in the table:</P>
<P align="center">
<CENTER>
<TABLE id="Table3" cellSpacing="1" cellPadding="7" width="624" border="1">
<TBODY>
<TR>
<TD vAlign="top" width="50%"><B>
<P>
Element</B>
</P>
</TD>
<TD vAlign="top" width="50%"><B>
<P>
Value</B> </P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>empty()</P>
</TD>
<TD vAlign="top" width="50%">
<P>m.empty().</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>size()</P>
</TD>
<TD vAlign="top" width="50%">
<P>m.size().</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>str(n)</P>
</TD>
<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%">
<P>prefix()</P>
</TD>
<TD vAlign="top" width="50%">
<P>m.prefix().</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>suffix()</P>
</TD>
<TD vAlign="top" width="50%">
<P>m.suffix().</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>(*this)[n]</P>
</TD>
<TD vAlign="top" width="50%">
<P>m[n] for all integers n &lt; m.size().</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>length(n)</P>
</TD>
<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%">
<P>position(n)</P>
</TD>
<TD vAlign="top" width="50%">
<P>m.position(n) for all integers n &lt; m.size().</P>
<P></P>
</TD>
</TR>
</TBODY></TD></TR></TABLE></CENTER>
<P></P>
<DIV></DIV>
<H4>match_results size</H4>
<PRE>size_type size()const;</PRE>
<B>
<P>
Effects:</B> Returns the number of sub_match elements stored in *this.</P><PRE>size_type max_size()const;</PRE>
<B>
<P>
Effects:</B> Returns the maximum number of sub_match elements that can be
stored in *this.</P><PRE>bool empty()const;</PRE>
<B>
<P>
Effects:</B> Returns <CODE>size() == 0</CODE>.</P>
<H4>match_results element access</H4>
<PRE>difference_type length(int sub = 0)const;</PRE>
<B>
<P>
Effects:</B> Returns <CODE>(*this)[sub].length()</CODE>.</P><PRE>difference_type position(unsigned int sub = 0)const;</PRE>
<B>
<P>
Effects:</B> Returns <CODE>std::distance(prefix().first,
(*this)[sub].first).</P></CODE><PRE>string_type str(int sub = 0)const;</PRE>
<B>
<P>
Effects:</B> Returns <CODE>string_type((*this)[sub]).</P></CODE><PRE>const_reference operator[](int n) const;</PRE>
<B>
<P>
Effects:</B> Returns a reference to the <CODE>sub_match </CODE>object
representing the character sequence that matched marked sub-expression <I>n</I>.
If <CODE>n == 0 </CODE>then returns a reference to a <CODE>sub_match</CODE> object
representing the character sequence that matched the whole regular
expression.</P><PRE>const_reference prefix()const;</PRE>
<B>
<P>
Effects:</B> Returns a reference to the <CODE>sub_match </CODE>object
representing the character sequence from the start of the string being
matched/searched, to the start of the match found.</P><PRE>const_reference suffix()const;</PRE>
<B>
<P>
Effects:</B> Returns a reference to the <CODE>sub_match </CODE>object
representing the character sequence from the end of the match found to the end
of the string being matched/searched.</P><PRE>const_iterator begin()const;</PRE>
<B>
<P>
Effects:</B> Returns a starting iterator that enumerates over all the marked
sub-expression matches stored in *this.</P><PRE>const_iterator end()const;</PRE>
<B>
<P>
Effects:</B> Returns a terminating iterator that enumerates over all the
marked sub-expression matches stored in *this.</P>
<H4>match_results reformatting</H4>
<PRE>template &lt;class OutputIterator&gt;
match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m2);
</pre>
<h3><a name="description"></a>Description</h3>
<h4>match_results constructors</h4>
<p>In all <code>match_results</code> constructors, a copy of the
Allocator argument is used for any memory allocation performed by
the constructor or member functions during the lifetime of the
object.</p>
<pre>
match_results(const Allocator&amp; a = Allocator());
</pre>
<b></b>
<p><b>Effects:</b> Constructs an object of class match_results. The
postconditions 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">
<tbody>
<tr>
<td valign="top" width="50%"><b></b>
<p><b>Element</b></p>
</td>
<td valign="top" width="50%"><b></b>
<p><b>Value</b></p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>empty()</p>
</td>
<td valign="top" width="50%">
<p>true</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>size()</p>
</td>
<td valign="top" width="50%">
<p>0</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>str()</p>
</td>
<td valign="top" width="50%">
<p>basic_string&lt;charT&gt;()</p>
</td>
</tr>
</tbody>
</table>
</center>
<p>&nbsp;</p>
<pre>
match_results(const match_results&amp; m);
</pre>
<b></b>
<p><b>Effects:</b> Constructs an object of class match_results, as
a copy of m.</p>
<pre>
match_results&amp; operator=(const match_results&amp; m);
</pre>
<b></b>
<p><b>Effects:</b> Assigns m to *this. The postconditions of this
function are indicated in the table:</p>
<p align="center"></p>
<center>
<table id="Table3" cellspacing="1" cellpadding="7" width="624"
border="1">
<tbody>
<tr>
<td valign="top" width="50%"><b></b>
<p><b>Element</b></p>
</td>
<td valign="top" width="50%"><b></b>
<p><b>Value</b></p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>empty()</p>
</td>
<td valign="top" width="50%">
<p>m.empty().</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>size()</p>
</td>
<td valign="top" width="50%">
<p>m.size().</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>str(n)</p>
</td>
<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%">
<p>prefix()</p>
</td>
<td valign="top" width="50%">
<p>m.prefix().</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>suffix()</p>
</td>
<td valign="top" width="50%">
<p>m.suffix().</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>(*this)[n]</p>
</td>
<td valign="top" width="50%">
<p>m[n] for all integers n &lt; m.size().</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>length(n)</p>
</td>
<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%">
<p>position(n)</p>
</td>
<td valign="top" width="50%">
<p>m.position(n) for all integers n &lt; m.size().</p>
</td>
</tr>
</tbody>
</table>
</center>
<h4>match_results size</h4>
<pre>
size_type size()const;
</pre>
<b></b>
<p><b>Effects:</b> Returns the number of sub_match elements stored
in *this.</p>
<pre>
size_type max_size()const;
</pre>
<b></b>
<p><b>Effects:</b> Returns the maximum number of sub_match elements
that can be stored in *this.</p>
<pre>
bool empty()const;
</pre>
<b></b>
<p><b>Effects:</b> Returns <code>size() == 0</code>.</p>
<h4>match_results element access</h4>
<pre>
difference_type length(int sub = 0)const;
</pre>
<b></b>
<p><b>Effects:</b> Returns <code>(*this)[sub].length()</code>.</p>
<pre>
difference_type position(unsigned int sub = 0)const;
</pre>
<b></b>
<p><b>Effects:</b> Returns <code>std::distance(prefix().first,
(*this)[sub].first).</code></p>
<pre>
string_type str(int sub = 0)const;
</pre>
<b></b>
<p><b>Effects:</b> Returns <code>
string_type((*this)[sub]).</code></p>
<pre>
const_reference operator[](int n) const;
</pre>
<b></b>
<p><b>Effects:</b> Returns a reference to the <code>
sub_match</code> object representing the character sequence that
matched marked sub-expression <i>n</i>. If <code>n == 0</code> then
returns a reference to a <code>sub_match</code> object representing
the character sequence that matched the whole regular
expression.</p>
<pre>
const_reference prefix()const;
</pre>
<b></b>
<p><b>Effects:</b> Returns a reference to the <code>
sub_match</code> object representing the character sequence from
the start of the string being matched/searched, to the start of the
match found.</p>
<pre>
const_reference suffix()const;
</pre>
<b></b>
<p><b>Effects:</b> Returns a reference to the <code>
sub_match</code> object representing the character sequence from
the end of the match found to the end of the string being
matched/searched.</p>
<pre>
const_iterator begin()const;
</pre>
<b></b>
<p><b>Effects:</b> Returns a starting iterator that enumerates over
all the marked sub-expression matches stored in *this.</p>
<pre>
const_iterator end()const;
</pre>
<b></b>
<p><b>Effects:</b> Returns a terminating iterator that enumerates
over all the marked sub-expression matches stored in *this.</p>
<h4>match_results reformatting</h4>
<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);</PRE>
<B>
<P>
Requires: </B>The type OutputIterator conforms to the Output Iterator
requirements (24.1.2).</P><B>
<P>
Effects:</B> Copies the character sequence <I>[fmt.begin(), fmt.end())</I> to
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
the format used by ECMA-262, ECMAScript Language Specification, Chapter 15 part
5.4.11 String.prototype.replace.</P><B>
<P>
Returns:</B> <I>out</I>.</P><PRE>string_type format(const string_type&amp; fmt,
<A href="match_flag_type.html">match_flag_type</A> flags = format_default);</PRE>
<B>
<P>
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,
ECMAScript Language Specification, Chapter 15 part 5.4.11
String.prototype.replace.</P><PRE>allocator_type get_allocator()const;</PRE>
<B>
<P>
Effects:</B> Returns a copy of the Allocator that was passed to the object's
constructor.</P><PRE>void swap(match_results&amp; that);</PRE>
<B>
<P>
Effects:</B> Swaps the contents of the two sequences. </P><B>
<P>
Postcondition:</B> <CODE>*this</CODE> contains the sequence of matched
sub-expressions that were in <CODE>that</CODE>, <CODE>that</CODE> contains the
sequence of matched sub-expressions that were in <CODE>*this</CODE>. </P><B>
<P>
Complexity:</B> constant time.
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
<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 requirements (24.1.2).</p>
<b></b>
<p><b>Effects:</b> Copies the character sequence <i>[fmt.begin(),
fmt.end())</i> to 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 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>
string_type format(const string_type&amp; fmt,
<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, ECMAScript Language Specification,
Chapter 15 part 5.4.11 String.prototype.replace.</p>
<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>
void swap(match_results&amp; that);
</pre>
<b></b>
<p><b>Effects:</b> Swaps the contents of the two sequences.</p>
<b></b>
<p><b>Postcondition:</b> <code>*this</code> contains the sequence
of matched sub-expressions that were in <code>that</code>, <code>
that</code> contains the sequence of matched sub-expressions that
were in <code>*this</code>.</p>
<b></b>
<p><b>Complexity:</b> constant time.</p>
<p></p>
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
<p><i>&copy; Copyright <a href="mailto:jm@regex.fsnet.co.uk">John
Maddock</a>&nbsp;1998-
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
<p align="left"><i>Permission to use, copy, modify, distribute and
sell this software and its documentation for any purpose is hereby
granted without fee, provided that the above copyright notice
appear in all copies and that both that copyright notice and this
permission notice appear in supporting documentation. Dr John
Maddock makes no representations about the suitability of this
software for any purpose. It is provided "as is" without express or
implied warranty.</i></p>
</body>
</html>

View File

@ -170,7 +170,7 @@ void search(std::istream&amp; is)
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
@ -182,3 +182,4 @@ void search(std::istream&amp; is)
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -0,0 +1,54 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Performance</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">Performance</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>
<P>The performance of Boost.regex in both recursive and non-recursive modes should
be broadly comparable to other regular expression libraries: recursive mode is
slightly faster (especially where memory allocation requires thread
synchronisation), but not by much.&nbsp; The following pages compare
Boost.regex with various other regular expression libraries for the following
compilers:</P>
<P><A href="vc71-performance.html">Visual Studio.Net 2003 (recursive Boost.regex
implementation)</A>.</P>
<P><A href="gcc-performance.html">Gcc 3.2 (cygwin) (non-recursive Boost.regex
implementation).</A></P>
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -273,7 +273,7 @@
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
@ -285,3 +285,4 @@
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -69,7 +69,7 @@
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
@ -81,3 +81,4 @@
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -31,7 +31,7 @@
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
@ -43,3 +43,4 @@
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -1,55 +1,91 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: regbase</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">regbase</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>
<P>Use of the type <code>boost::regbase</code> is now deprecated, and the type does not form a
part of the <A href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1429.htm">
regular expression standardization proposal</A>.&nbsp; This type still
exists as a base class of <code>boost::basic_regex</code>, and you can still refer to
<code>boost::regbase::constant_name</code> in your code, however for maximum portability to
other std regex implementations you should instead use either:</P>
<PRE>boost::regex_constants::constant_name</PRE>
<P>or</P>
<PRE>boost::regex::constant_name</PRE>
<P>or</P>
<PRE>boost::wregex::constant_name</PRE>
<P>
<HR>
</P>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<title>Boost.Regex: regbase</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></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">regbase</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>
<br>
<br>
<hr>
<p>Use of the type <code>boost::regbase</code> is now deprecated,
and the type does not form a part of the <a href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1429.htm">
regular expression standardization proposal</a>.&nbsp; This type
still exists as a base class of <code>boost::basic_regex</code>,
and you can still refer to <code>
boost::regbase::constant_name</code> in your code, however for
maximum portability to other std regex implementations you should
instead use either:</p>
<pre>
boost::regex_constants::constant_name
</pre>
<p>or</p>
<pre>
boost::regex::constant_name
</pre>
<p>or</p>
<pre>
boost::wregex::constant_name
</pre>
<p></p>
<hr>
<br>
<br>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
<p><i>&copy; Copyright <a href="mailto:jm@regex.fsnet.co.uk">John
Maddock</a>&nbsp;1998-
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
<p align="left"><i>Permission to use, copy, modify, distribute and
sell this software and its documentation for any purpose is hereby
granted without fee, provided that the above copyright notice
appear in all copies and that both that copyright notice and this
permission notice appear in supporting documentation. Dr John
Maddock makes no representations about the suitability of this
software for any purpose. It is provided "as is" without express or
implied warranty.</i></p>
</body>
</html>

File diff suppressed because it is too large Load Diff

View File

@ -1,158 +1,213 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Algorithm regex_format (deprecated)</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">Algorithm regex_format (deprecated)</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>
<P>The algorithm regex_format is deprecated; new code should use
match_results::format instead.&nbsp; Existing code will continue to compile,
the following documentation is taken from the previous version of boost.regex
and will not be further updated:</P>
<H3>Algorithm regex_format</H3>
<H3></H3>
<PRE>#include &lt;<A href="../../boost/regex.hpp">boost/regex.hpp</A>&gt; </PRE>
<P>The algorithm regex_format takes the results of a match and creates a new
string based upon a <A href="format_syntax.html">format string</A>,
regex_format can be used for search and replace operations:
</P>
<PRE><B>template</B> &lt;<B>class</B> OutputIterator, <B>class</B> iterator, <B>class</B> Allocator, <B>class</B> charT&gt;
OutputIterator regex_format(OutputIterator out,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>const</B> match_results&lt;iterator, Allocator&gt;&amp; m,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>const</B> charT* fmt,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; match_flag_type flags = 0);
<B>
template</B> &lt;<B>class</B> OutputIterator, <B>class</B> iterator, <B>class</B> Allocator, <B>class</B> charT&gt;
OutputIterator regex_format(OutputIterator out,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>const</B> match_results&lt;iterator, Allocator&gt;&amp; m,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>const</B> std::basic_string&lt;charT&gt;&amp; fmt,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; match_flag_type flags = 0);</PRE>
<P>The library also defines the following convenience variation of regex_format,
which returns the result directly as a string, rather than outputting to an
iterator [note - this version may not be available, or may be available in a
more limited form, depending upon your compilers capabilities]:
</P>
<PRE><B>template</B> &lt;<B>class</B> iterator, <B>class</B> Allocator, <B>class</B> charT&gt;
std::basic_string&lt;charT&gt; regex_format
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (<B>const</B> match_results&lt;iterator, Allocator&gt;&amp; m,&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>const</B> charT* fmt,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; match_flag_type flags = 0);
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<title>Boost.Regex: Algorithm regex_format (deprecated)</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></p>
<B>template</B> &lt;<B>class</B> iterator, <B>class</B> Allocator, <B>class</B> charT&gt;
<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">Algorithm regex_format (deprecated)</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>
<br>
<br>
<hr>
<p>The algorithm regex_format is deprecated; new code should use
match_results::format instead.&nbsp; Existing code will continue to
compile, the following documentation is taken from the previous
version of boost.regex and will not be further updated:</p>
<h3>Algorithm regex_format</h3>
<pre>
#include &lt;<a href="../../boost/regex.hpp">boost/regex.hpp</a>&gt;
</pre>
<p>The algorithm regex_format takes the results of a match and
creates a new string based upon a <a href="format_syntax.html">
format string</a>, regex_format can be used for search and replace
operations:</p>
<pre>
<b>template</b> &lt;<b>class</b> OutputIterator, <b>class</b> iterator, <b>class</b> Allocator, <b>class</b> charT&gt;
OutputIterator regex_format(OutputIterator out,
<b>const</b> match_results&lt;iterator, Allocator&gt;&amp; m,
<b>const</b> charT* fmt,
match_flag_type flags = 0);
<b>template</b> &lt;<b>class</b> OutputIterator, <b>class</b> iterator, <b>class</b> Allocator, <b>class</b> charT&gt;
OutputIterator regex_format(OutputIterator out,
<b>const</b> match_results&lt;iterator, Allocator&gt;&amp; m,
<b>const</b> std::basic_string&lt;charT&gt;&amp; fmt,
match_flag_type flags = 0);
</pre>
<p>The library also defines the following convenience variation of
regex_format, which returns the result directly as a string, rather
than outputting to an iterator [note - this version may not be
available, or may be available in a more limited form, depending
upon your compilers capabilities]:</p>
<pre>
<b>template</b> &lt;<b>class</b> iterator, <b>class</b> Allocator, <b>class</b> charT&gt;
std::basic_string&lt;charT&gt; regex_format
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (<B>const</B> match_results&lt;iterator, Allocator&gt;&amp; m,&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>const</B> std::basic_string&lt;charT&gt;&amp; fmt,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; match_flag_type flags = 0);</PRE>
<P>Parameters to the main version of the function are passed as follows:
</P>
<P>
<TABLE id="Table2" cellSpacing="0" cellPadding="7" width="100%" border="0">
<TR>
<TD vAlign="top" width="9%">&nbsp;</TD>
<TD vAlign="top" width="39%">OutputIterator out</TD>
<TD vAlign="top" width="44%">An output iterator type, the output string is sent to
this iterator. Typically this would be a std::ostream_iterator.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="9%">&nbsp;</TD>
<TD vAlign="top" width="39%"><B>const</B> match_results&lt;iterator,
Allocator&gt;&amp; m</TD>
<TD vAlign="top" width="44%">An instance of match_results&lt;&gt; obtained from
one of the matching algorithms above, and denoting what matched.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="9%">&nbsp;</TD>
<TD vAlign="top" width="39%"><B>const</B> charT* fmt</TD>
<TD vAlign="top" width="44%">A format string that determines how the match is
transformed into the new string.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="9%">&nbsp;</TD>
<TD vAlign="top" width="39%"><B>unsigned</B> flags</TD>
<TD vAlign="top" width="44%">Optional flags which describe how the format string
is to be interpreted.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
</TABLE>
</P>
<P><A name="format_flags"></A>Format flags are defined as follows:
</P>
<P>
<TABLE id="Table3" cellSpacing="0" cellPadding="7" width="100%" border="0">
<TR>
<TD vAlign="top" width="9%">&nbsp;</TD>
<TD vAlign="top" width="39%">format_all</TD>
<TD vAlign="top" width="43%">Enables all syntax options (perl-like plus
extentions).</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="9%">&nbsp;</TD>
<TD vAlign="top" width="39%">format_sed</TD>
<TD vAlign="top" width="43%">Allows only a sed-like syntax.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="9%">&nbsp;</TD>
<TD vAlign="top" width="39%">format_perl</TD>
<TD vAlign="top" width="43%">Allows only a perl-like syntax.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="9%">&nbsp;</TD>
<TD vAlign="top" width="39%">format_no_copy</TD>
<TD vAlign="top" width="43%">Disables copying of unmatched sections to the output
string during <A href="regex_merge.html">regex_merge</A> operations.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD>format_first_only</TD>
<TD>When this flag is set only the first occurance will be replaced (applies to
regex_merge only).</TD>
<TD>&nbsp;</TD>
</TR>
</TABLE>
</P>
<P>The format string syntax (and available options) is described more fully under <A href="format_syntax.html">
format strings</A>
.
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
(<b>const</b> match_results&lt;iterator, Allocator&gt;&amp; m,
<b>const</b> charT* fmt,
match_flag_type flags = 0);
<b>template</b> &lt;<b>class</b> iterator, <b>class</b> Allocator, <b>class</b> charT&gt;
std::basic_string&lt;charT&gt; regex_format
(<b>const</b> match_results&lt;iterator, Allocator&gt;&amp; m,
<b>const</b> std::basic_string&lt;charT&gt;&amp; fmt,
match_flag_type flags = 0);
</pre>
<p>Parameters to the main version of the function are passed as
follows:</p>
<p></p>
<table id="Table2" cellspacing="0" cellpadding="7" width="100%"
border="0">
<tr>
<td valign="top" width="9%">&nbsp;</td>
<td valign="top" width="39%">OutputIterator out</td>
<td valign="top" width="44%">An output iterator type, the output
string is sent to this iterator. Typically this would be a
std::ostream_iterator.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="9%">&nbsp;</td>
<td valign="top" width="39%"><b>const</b>
match_results&lt;iterator, Allocator&gt;&amp; m</td>
<td valign="top" width="44%">An instance of match_results&lt;&gt;
obtained from one of the matching algorithms above, and denoting
what matched.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="9%">&nbsp;</td>
<td valign="top" width="39%"><b>const</b> charT* fmt</td>
<td valign="top" width="44%">A format string that determines how
the match is transformed into the new string.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="9%">&nbsp;</td>
<td valign="top" width="39%"><b>unsigned</b> flags</td>
<td valign="top" width="44%">Optional flags which describe how the
format string is to be interpreted.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
</table>
<br>
<br>
<p><a name="format_flags"></a>Format flags are defined as
follows:</p>
<p></p>
<table id="Table3" cellspacing="0" cellpadding="7" width="100%"
border="0">
<tr>
<td valign="top" width="9%">&nbsp;</td>
<td valign="top" width="39%">format_all</td>
<td valign="top" width="43%">Enables all syntax options (perl-like
plus extentions).</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="9%">&nbsp;</td>
<td valign="top" width="39%">format_sed</td>
<td valign="top" width="43%">Allows only a sed-like syntax.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="9%">&nbsp;</td>
<td valign="top" width="39%">format_perl</td>
<td valign="top" width="43%">Allows only a perl-like syntax.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="9%">&nbsp;</td>
<td valign="top" width="39%">format_no_copy</td>
<td valign="top" width="43%">Disables copying of unmatched sections
to the output string during <a href="regex_merge.html">
regex_merge</a> operations.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>format_first_only</td>
<td>When this flag is set only the first occurance will be replaced
(applies to regex_merge only).</td>
<td>&nbsp;</td>
</tr>
</table>
<br>
<br>
<p>The format string syntax (and available options) is described
more fully under <a href="format_syntax.html">format strings</a>
.</p>
<p></p>
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
<p><i>&copy; Copyright <a href="mailto:jm@regex.fsnet.co.uk">John
Maddock</a>&nbsp;1998-
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
<p align="left"><i>Permission to use, copy, modify, distribute and
sell this software and its documentation for any purpose is hereby
granted without fee, provided that the above copyright notice
appear in all copies and that both that copyright notice and this
permission notice appear in supporting documentation. Dr John
Maddock makes no representations about the suitability of this
software for any purpose. It is provided "as is" without express or
implied warranty.</i></p>
</body>
</html>

View File

@ -2,140 +2,148 @@
<html>
<head>
<title>Boost.Regex: Algorithm regex_grep (deprecated)</title>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<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">Algorithm regex_grep (deprecated)</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>
<P>The algorithm regex_grep is deprecated in favor of <A href="regex_iterator.html">regex_iterator</A>
which provides a more convenient and standard library friendly interface.</P>
<P>The following documentation is taken unchanged from the previous boost release,
and will not be updated in future.</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">Algorithm regex_grep (deprecated)</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>
<br>
<br>
<hr>
<PRE>#include &lt;<A href="../../boost/regex.hpp">boost/regex.hpp</A>&gt; </PRE>
<P>regex_grep allows you to search through a bidirectional-iterator range and
<p>The algorithm regex_grep is deprecated in favor of <a href="regex_iterator.html">regex_iterator</a>
which provides a more convenient and standard library friendly interface.</p>
<p>The following documentation is taken unchanged from the previous boost release,
and will not be updated in future.</p>
<hr>
<pre>
#include &lt;<a href="../../boost/regex.hpp">boost/regex.hpp</a>&gt;
</pre>
<p>regex_grep allows you to search through a bidirectional-iterator range and
locate all the (non-overlapping) matches with a given regular expression. The
function is declared as:
</P>
<PRE><B>template</B> &lt;<B>class</B> Predicate, <B>class</B> iterator, <B>class</B> charT, <B>class</B> traits, <B>class</B> Allocator&gt;
<B>unsigned</B> <B>int</B> regex_grep(Predicate foo,
function is declared as:</p>
<pre>
<b>template</b> &lt;<b>class</b> Predicate, <b>class</b> iterator, <b>class</b> charT, <b>class</b> traits, <b>class</b> Allocator&gt;
<b>unsigned</b> <b>int</b> regex_grep(Predicate foo,
iterator first,
iterator last,
<B>const</B> basic_regex&lt;charT, traits, Allocator&gt;&amp; e,
<B>unsigned</B> flags = match_default)</PRE>
<P>The library also defines the following convenience versions, which take either
<b>const</b> basic_regex&lt;charT, traits, Allocator&gt;&amp; e,
<b>unsigned</b> flags = match_default)
</pre>
<p>The library also defines the following convenience versions, which take either
a const charT*, or a const std::basic_string&lt;&gt;&amp; in place of a pair of
iterators [note - these versions may not be available, or may be available in a
more limited form, depending upon your compilers capabilities]:
</P>
<PRE><B>template</B> &lt;<B>class</B> Predicate, <B>class</B> charT, <B>class</B> Allocator, <B>class</B> traits&gt;
<B>unsigned</B> <B>int</B> regex_grep(Predicate foo,&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>const</B> charT* str,&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>const</B> basic_regex&lt;charT, traits, Allocator&gt;&amp; e,&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>unsigned</B> flags = match_default);
more limited form, depending upon your compilers capabilities]:</p>
<pre>
<b>template</b> &lt;<b>class</b> Predicate, <b>class</b> charT, <b>class</b> Allocator, <b>class</b> traits&gt;
<b>unsigned</b> <b>int</b> regex_grep(Predicate foo,
<b>const</b> charT* str,
<b>const</b> basic_regex&lt;charT, traits, Allocator&gt;&amp; e,
<b>unsigned</b> flags = match_default);
<B>template</B> &lt;<B>class</B> Predicate, <B>class</B> ST, <B>class</B> SA, <B>class</B> Allocator, <B>class</B> charT, <B>class</B> traits&gt;
<B>unsigned</B> <B>int</B> regex_grep(Predicate foo,&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>const</B> std::basic_string&lt;charT, ST, SA&gt;&amp; s,&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>const</B> basic_regex&lt;charT, traits, Allocator&gt;&amp; e,&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>unsigned</B> flags = match_default);</PRE>
<P>The parameters for the primary version of regex_grep have the following
meanings:&nbsp;
</P>
<P>
<TABLE id="Table2" cellSpacing="0" cellPadding="7" width="624" border="0">
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="50%">foo</TD>
<TD vAlign="top" width="50%">A predicate function object or function pointer, see
below for more information.</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">first</TD>
<TD vAlign="top" width="50%">The start of the range to search.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">last</TD>
<TD vAlign="top" width="50%">The end of the range to search.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">e</TD>
<TD vAlign="top" width="50%">The regular expression to search for.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">flags</TD>
<TD vAlign="top" width="50%">The flags that determine how matching is carried out,
one of the <A href="#match_type">match_flags</A> enumerators.</TD>
<TD>&nbsp;</TD>
</TR>
</TABLE>
</P>
<P>The algorithm finds all of the non-overlapping matches of the expression e, for
each match it fills a <A href="#reg_match">match_results</A>&lt;iterator,
<b>template</b> &lt;<b>class</b> Predicate, <b>class</b> ST, <b>class</b> SA, <b>class</b> Allocator, <b>class</b> charT, <b>class</b> traits&gt;
<b>unsigned</b> <b>int</b> regex_grep(Predicate foo,
<b>const</b> std::basic_string&lt;charT, ST, SA&gt;&amp; s,
<b>const</b> basic_regex&lt;charT, traits, Allocator&gt;&amp; e,
<b>unsigned</b> flags = match_default);
</pre>
<p>The parameters for the primary version of regex_grep have the following
meanings:&nbsp;</p>
<p></p>
<table id="Table2" cellspacing="0" cellpadding="7" width="624" border="0">
<tr>
<td width="5%">&nbsp;</td>
<td valign="top" width="50%">foo</td>
<td valign="top" width="50%">A predicate function object or function pointer, see
below for more information.</td>
<td width="5%">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td valign="top" width="50%">first</td>
<td valign="top" width="50%">The start of the range to search.</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td valign="top" width="50%">last</td>
<td valign="top" width="50%">The end of the range to search.</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td valign="top" width="50%">e</td>
<td valign="top" width="50%">The regular expression to search for.</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td valign="top" width="50%">flags</td>
<td valign="top" width="50%">The flags that determine how matching is carried out,
one of the <a href="#match_type">match_flags</a> enumerators.</td>
<td>&nbsp;</td>
</tr>
</table>
<br>
<br>
<p>The algorithm finds all of the non-overlapping matches of the expression e, for
each match it fills a <a href="#reg_match">match_results</a>&lt;iterator,
Allocator&gt; structure, which contains information on what matched, and calls
the predicate foo, passing the match_results&lt;iterator, Allocator&gt; as a
single argument. If the predicate returns true, then the grep operation
continues, otherwise it terminates without searching for further matches. The
function returns the number of matches found.</P>
<P>The general form of the predicate is:
</P>
<PRE><B>struct</B> grep_predicate
function returns the number of matches found.</p>
<p>The general form of the predicate is:</p>
<pre>
<b>struct</b> grep_predicate
{
<B>&nbsp;&nbsp; bool</B> <B>operator</B>()(<B>const</B> match_results&lt;iterator_type, typename expression_type::alloc_type::template rebind&lt;sub_match&lt;BidirectionalIterator&gt; &gt;::other&gt;&amp; m);
};</PRE>
<P>Note that in almost every case the allocator parameter can be omitted, when
specifying the <A href="match_results.html">match_results</A> type,
<b> bool</b> <b>operator</b>()(<b>const</b> match_results&lt;iterator_type, typename expression_type::alloc_type::template rebind&lt;sub_match&lt;BidirectionalIterator&gt; &gt;::other&gt;&amp; m);
};
</pre>
<p>Note that in almost every case the allocator parameter can be omitted, when
specifying the <a href="match_results.html">match_results</a> type,
alternatively one of the typedefs cmatch, wcmatch, smatch or wsmatch can be
used.
</P>
<P>For example the regular expression "a*b" would find one match in the string
"aaaaab" and two in the string "aaabb".
</P>
<P>Remember this algorithm can be used for a lot more than implementing a version
used.</p>
<p>For example the regular expression "a*b" would find one match in the string
"aaaaab" and two in the string "aaabb".</p>
<p>Remember this algorithm can be used for a lot more than implementing a version
of grep, the predicate can be and do anything that you want, grep utilities
would output the results to the screen, another program could index a file
based on a regular expression and store a set of bookmarks in a list, or a text
file conversion utility would output to file. The results of one regex_grep can
even be chained into another regex_grep to create recursive parsers.
</P>
<P><A href="../example/snippets/regex_grep_example_1.cpp">Example</A>: convert the
example from <I>regex_search</I> to use <I>regex_grep</I> instead:
</P>
<PRE><FONT color=#008000>#include &lt;string&gt;
even be chained into another regex_grep to create recursive parsers.</p>
<P>The algorithm may throw&nbsp;<CODE>std::runtime_error</CODE> if the complexity
of matching the expression against an N character string begins to exceed O(N<SUP>2</SUP>),
or if the program runs out of stack space while matching the expression (if
Boost.regex is <A href="configuration.html">configured</A> in recursive mode),
or if the matcher exhausts it's permitted memory allocation (if Boost.regex is <A href="configuration.html">
configured</A> in non-recursive mode).</P>
<p><a href="../example/snippets/regex_grep_example_1.cpp"> Example</a>: convert
the example from <i>regex_search</i> to use <i>regex_grep</i> instead:</p>
<pre>
<font color="#008000">#include &lt;string&gt;
#include &lt;map&gt;
#include &lt;boost/regex.hpp&gt;
</FONT><FONT color=#000080><I>// IndexClasses:
</font><font color="#000080"><i>// IndexClasses:
// takes the contents of a file in the form of a string
// and searches for all the C++ class definitions, storing
// their locations in a map of strings/int's
</I></FONT><B>
typedef</B> std::map&lt;std::string, <B>int</B>, std::less&lt;std::string&gt; &gt; map_type;
</i></font><b>typedef</b> std::map&lt;std::string, <b>int</b>, std::less&lt;std::string&gt; &gt; map_type;
const char* re =
// possibly leading whitespace:
@ -160,45 +168,44 @@ const char* re =
"(\\{|:[^;\\{()]*\\{)";
boost::regex expression(re);
<B>
class</B> IndexClassesPred
<b>class</b> IndexClassesPred
{
&nbsp;&nbsp; map_type&amp; m;
&nbsp;&nbsp; std::string::const_iterator base;
<B>public</B>:
&nbsp;&nbsp; IndexClassesPred(map_type&amp; a, std::string::const_iterator b) : m(a), base(b) {}
&nbsp;&nbsp; <B>bool</B> <B>operator</B>()(<B>const</B> smatch&amp; what)
&nbsp;&nbsp; {
<FONT color=#000080>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <I>// what[0] contains the whole string
</I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <I>// what[5] contains the class name.
</I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <I>// what[6] contains the template specialisation if any.
</I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <I>// add class name and position to map:
</I></FONT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m[std::string(what[5].first, what[5].second) + std::string(what[6].first, what[6].second)] =&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; what[5].first - base;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>return</B> <B>true</B>;
&nbsp;&nbsp; }
map_type&amp; m;
std::string::const_iterator base;
<b>public</b>:
IndexClassesPred(map_type&amp; a, std::string::const_iterator b) : m(a), base(b) {}
<b>bool</b> <b>operator</b>()(<b>const</b> smatch&amp; what)
{
<font color=
#000080> <i>// what[0] contains the whole string
</i> <i>// what[5] contains the class name.
</i> <i>// what[6] contains the template specialisation if any.
</i> <i>// add class name and position to map:
</i></font> m[std::string(what[5].first, what[5].second) + std::string(what[6].first, what[6].second)] =
what[5].first - base;
<b>return</b> <b>true</b>;
}
};
<B>
void</B> IndexClasses(map_type&amp; m, <B>const</B> std::string&amp; file)
<b>void</b> IndexClasses(map_type&amp; m, <b>const</b> std::string&amp; file)
{
&nbsp;&nbsp; std::string::const_iterator start, end;
&nbsp;&nbsp; start = file.begin();
&nbsp;&nbsp; end = file.end();
&nbsp;&nbsp; regex_grep(IndexClassesPred(m, start), start, end, expression);
} </PRE>
<P><A href="../example/snippets/regex_grep_example_2.cpp">Example</A>: Use
regex_grep to call a global callback function:
</P>
<PRE><FONT color=#008000>#include &lt;string&gt;
std::string::const_iterator start, end;
start = file.begin();
end = file.end();
regex_grep(IndexClassesPred(m, start), start, end, expression);
}
</pre>
<p><a href="../example/snippets/regex_grep_example_2.cpp"> Example</a>: Use
regex_grep to call a global callback function:</p>
<pre>
<font color="#008000">#include &lt;string&gt;
#include &lt;map&gt;
#include &lt;boost/regex.hpp&gt;
</FONT><FONT color=#000080><I>// purpose:
</font><font color="#000080"><i>// purpose:
// takes the contents of a file in the form of a string
// and searches for all the C++ class definitions, storing
// their locations in a map of strings/int's
</I></FONT><B>
typedef</B> std::map&lt;std::string, <B>int</B>, std::less&lt;std::string&gt; &gt; map_type;
</i></font><b>typedef</b> std::map&lt;std::string, <b>int</b>, std::less&lt;std::string&gt; &gt; map_type;
const char* re =
// possibly leading whitespace:
@ -226,152 +233,154 @@ boost::regex expression(re);
map_type class_index;
std::string::const_iterator base;
<B>bool</B> grep_callback(<B>const</B> boost::smatch&amp; what)
<b>bool</b> grep_callback(<b>const</b> boost::smatch&amp; what)
{
<FONT color=#000080>&nbsp;&nbsp; <I>// what[0] contains the whole string
</I>&nbsp;&nbsp; <I>// what[5] contains the class name.
</I>&nbsp;&nbsp; <I>// what[6] contains the template specialisation if any.
</I>&nbsp;&nbsp; <I>// add class name and position to map:
</I></FONT>&nbsp;&nbsp; class_index[std::string(what[5].first, what[5].second) + std::string(what[6].first, what[6].second)] =&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; what[5].first - base;
&nbsp;&nbsp; <B>return</B> <B>true</B>;
<font color="#000080"> <i>// what[0] contains the whole string
</i> <i>// what[5] contains the class name.
</i> <i>// what[6] contains the template specialisation if any.
</i> <i>// add class name and position to map:
</i></font> class_index[std::string(what[5].first, what[5].second) + std::string(what[6].first, what[6].second)] =
what[5].first - base;
<b>return</b> <b>true</b>;
}
<B>
void</B> IndexClasses(<B>const</B> std::string&amp; file)
<b>void</b> IndexClasses(<b>const</b> std::string&amp; file)
{
&nbsp;&nbsp; std::string::const_iterator start, end;
&nbsp;&nbsp; start = file.begin();
&nbsp;&nbsp; end = file.end();
&nbsp;&nbsp; base = start;
&nbsp;&nbsp; regex_grep(grep_callback, start, end, expression, match_default);
std::string::const_iterator start, end;
start = file.begin();
end = file.end();
base = start;
regex_grep(grep_callback, start, end, expression, match_default);
}
&nbsp; </PRE>
<P><A href="../example/snippets/regex_grep_example_3.cpp">Example</A>: use
regex_grep to call a class member function, use the standard library adapters <I>std::mem_fun</I>
and <I>std::bind1st</I> to convert the member function into a predicate:
</P>
<PRE><FONT color=#008000>#include &lt;string&gt;
</pre>
<p><a href="../example/snippets/regex_grep_example_3.cpp"> Example</a>: use
regex_grep to call a class member function, use the standard library adapters <i>std::mem_fun</i>
and <i>std::bind1st</i> to convert the member function into a predicate:</p>
<pre>
<font color="#008000">#include &lt;string&gt;
#include &lt;map&gt;
#include &lt;boost/regex.hpp&gt;
#include &lt;functional&gt;
</FONT><FONT color=#000080><I>
// purpose:
</font><font color="#000080"><i>// purpose:
// takes the contents of a file in the form of a string
// and searches for all the C++ class definitions, storing
// their locations in a map of strings/int's
</I></FONT><B>typedef</B> std::map&lt;std::string, <B>int</B>, std::less&lt;std::string&gt; &gt; map_type;
<B>
class</B> class_index
</i></font><b>typedef</b> std::map&lt;std::string, <b>int</b>, std::less&lt;std::string&gt; &gt; map_type;
<b>class</b> class_index
{
&nbsp;&nbsp; boost::regex expression;
&nbsp;&nbsp; map_type index;
&nbsp;&nbsp; std::string::const_iterator base;
&nbsp;&nbsp; <B>bool</B> grep_callback(boost::smatch what);
<B>public</B>:
<B>&nbsp;&nbsp; void</B> IndexClasses(<B>const</B> std::string&amp; file);
&nbsp;&nbsp; class_index()
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : index(),
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; expression(<FONT color=#000080>"^(template[[:space:]]*&lt;[^;:{]+&gt;[[:space:]]*)?"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "(class|struct)[[:space:]]*(\\&lt;\\w+\\&gt;([[:blank:]]*\\([^)]*\\))?"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "[[:space:]]*)*(\\&lt;\\w*\\&gt;)[[:space:]]*(&lt;[^;:{]+&gt;[[:space:]]*)?"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "(\\{|:[^;\\{()]*\\{)"
</FONT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ){}
boost::regex expression;
map_type index;
std::string::const_iterator base;
<b>bool</b> grep_callback(boost::smatch what);
<b>public</b>:
<b> void</b> IndexClasses(<b>const</b> std::string&amp; file);
class_index()
: index(),
expression(<font color=
#000080>"^(template[[:space:]]*&lt;[^;:{]+&gt;[[:space:]]*)?"
"(class|struct)[[:space:]]*(\\&lt;\\w+\\&gt;([[:blank:]]*\\([^)]*\\))?"
"[[:space:]]*)*(\\&lt;\\w*\\&gt;)[[:space:]]*(&lt;[^;:{]+&gt;[[:space:]]*)?"
"(\\{|:[^;\\{()]*\\{)"
</font> ){}
};
<B>
bool</B> class_index::grep_callback(boost::smatch what)
<b>bool</b> class_index::grep_callback(boost::smatch what)
{
<FONT color=#000080>&nbsp;&nbsp; <I>// what[0] contains the whole string
</I>&nbsp;&nbsp; <I>// what[5] contains the class name.
</I>&nbsp;&nbsp; <I>// what[6] contains the template specialisation if any.
</I>&nbsp;&nbsp; <I>// add class name and position to map:
</I></FONT>&nbsp;&nbsp; index[std::string(what[5].first, what[5].second) + std::string(what[6].first, what[6].second)] =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; what[5].first - base;
&nbsp;&nbsp; <B>return</B> <B>true</B>;
<font color="#000080"> <i>// what[0] contains the whole string
</i> <i>// what[5] contains the class name.
</i> <i>// what[6] contains the template specialisation if any.
</i> <i>// add class name and position to map:
</i></font> index[std::string(what[5].first, what[5].second) + std::string(what[6].first, what[6].second)] =
what[5].first - base;
<b>return</b> <b>true</b>;
}
<B>void</B> class_index::IndexClasses(<B>const</B> std::string&amp; file)
<b>void</b> class_index::IndexClasses(<b>const</b> std::string&amp; file)
{
&nbsp;&nbsp; std::string::const_iterator start, end;
&nbsp;&nbsp; start = file.begin();
&nbsp;&nbsp; end = file.end();
&nbsp;&nbsp; base = start;
&nbsp;&nbsp; regex_grep(std::bind1st(std::mem_fun(&amp;class_index::grep_callback), <B>this</B>),
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; start,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; expression);
std::string::const_iterator start, end;
start = file.begin();
end = file.end();
base = start;
regex_grep(std::bind1st(std::mem_fun(&amp;class_index::grep_callback), <b>this</b>),
start,
end,
expression);
}
&nbsp; </PRE>
<P><A href="../example/snippets/regex_grep_example_4.cpp">Finally</A>, C++ Builder
users can use C++ Builder's closure type as a callback argument:
</P>
<PRE><FONT color=#008000>#include &lt;string&gt;
</pre>
<p><a href="../example/snippets/regex_grep_example_4.cpp"> Finally</a>, C++
Builder users can use C++ Builder's closure type as a callback argument:</p>
<pre>
<font color="#008000">#include &lt;string&gt;
#include &lt;map&gt;
#include &lt;boost/regex.hpp&gt;
#include &lt;functional&gt;
</FONT><FONT color=#000080><I>
// purpose:
</font><font color="#000080"><i>// purpose:
// takes the contents of a file in the form of a string
// and searches for all the C++ class definitions, storing
// their locations in a map of strings/int's
</I></FONT><B>typedef</B> std::map&lt;std::string, <B>int</B>, std::less&lt;std::string&gt; &gt; map_type;
<B>class</B> class_index
</i></font><b>typedef</b> std::map&lt;std::string, <b>int</b>, std::less&lt;std::string&gt; &gt; map_type;
<b>class</b> class_index
{
&nbsp;&nbsp; boost::regex expression;
&nbsp;&nbsp; map_type index;
&nbsp;&nbsp; std::string::const_iterator base;
&nbsp;&nbsp; <B>typedef</B> boost::smatch arg_type;
&nbsp;&nbsp; <B>bool</B> grep_callback(<B>const</B> arg_type&amp; what);
<B>public</B>:
&nbsp;&nbsp; <B>typedef</B> <B>bool</B> (<B>__closure</B>* grep_callback_type)(<B>const</B> arg_type&amp;);
&nbsp;&nbsp; <B>void</B> IndexClasses(<B>const</B> std::string&amp; file);
&nbsp;&nbsp; class_index()
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : index(),
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; expression(<FONT color=#000080>"^(template[[:space:]]*&lt;[^;:{]+&gt;[[:space:]]*)?"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "(class|struct)[[:space:]]*(\\&lt;\\w+\\&gt;([[:blank:]]*\\([^)]*\\))?"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "[[:space:]]*)*(\\&lt;\\w*\\&gt;)[[:space:]]*(&lt;[^;:{]+&gt;[[:space:]]*)?"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "(\\{|:[^;\\{()]*\\{)"
</FONT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ){}
boost::regex expression;
map_type index;
std::string::const_iterator base;
<b>typedef</b> boost::smatch arg_type;
<b>bool</b> grep_callback(<b>const</b> arg_type&amp; what);
<b>public</b>:
<b>typedef</b> <b>bool</b> (<b>__closure</b>* grep_callback_type)(<b>const</b> arg_type&amp;);
<b>void</b> IndexClasses(<b>const</b> std::string&amp; file);
class_index()
: index(),
expression(<font color=
#000080>"^(template[[:space:]]*&lt;[^;:{]+&gt;[[:space:]]*)?"
"(class|struct)[[:space:]]*(\\&lt;\\w+\\&gt;([[:blank:]]*\\([^)]*\\))?"
"[[:space:]]*)*(\\&lt;\\w*\\&gt;)[[:space:]]*(&lt;[^;:{]+&gt;[[:space:]]*)?"
"(\\{|:[^;\\{()]*\\{)"
</font> ){}
};
<B>bool</B> class_index::grep_callback(<B>const</B> arg_type&amp; what)
<b>bool</b> class_index::grep_callback(<b>const</b> arg_type&amp; what)
{
<FONT color=#000080>&nbsp;&nbsp; <I>// what[0] contains the whole string </I>&nbsp;&nbsp;
<I>// what[5] contains the class name. </I>&nbsp;&nbsp;
<I>// what[6] contains the template specialisation if any. </I>&nbsp;&nbsp;
<I>// add class name and position to map: </I></FONT>&nbsp;&nbsp;
<font color=
#000080> <i>// what[0] contains the whole string</i>
<i>// what[5] contains the class name.</i>
<i>// what[6] contains the template specialisation if any.</i>
<i>// add class name and position to map:</i></font>
index[std::string(what[5].first, what[5].second) + std::string(what[6].first, what[6].second)] =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; what[5].first - base;
&nbsp;&nbsp; <B>return</B> <B>true</B>;
what[5].first - base;
<b>return</b> <b>true</b>;
}
<B>void</B> class_index::IndexClasses(<B>const</B> std::string&amp; file)
<b>void</b> class_index::IndexClasses(<b>const</b> std::string&amp; file)
{
&nbsp;&nbsp; std::string::const_iterator start, end;
&nbsp;&nbsp; start = file.begin();
&nbsp;&nbsp; end = file.end();
&nbsp;&nbsp; base = start;
&nbsp;&nbsp; class_index::grep_callback_type cl = &amp;(<B>this</B>-&gt;grep_callback);
&nbsp;&nbsp; regex_grep(cl,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; start,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; expression);
} </PRE>
<P>
<HR>
<P></P>
std::string::const_iterator start, end;
start = file.begin();
end = file.end();
base = start;
class_index::grep_callback_type cl = &amp;(<b>this</b>-&gt;grep_callback);
regex_grep(cl,
start,
end,
expression);
}
</pre>
<p></p>
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
<p><i><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
<p align="left"><i>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
for any purpose. It is provided "as is" without express or implied warranty.</i></p>
</body>
</html>

View File

@ -2,35 +2,39 @@
<html>
<head>
<title>Boost.Regex: regex_iterator</title>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<LINK href="../../../boost.css" type="text/css" rel="stylesheet"></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" 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">regex_iterator</H2>
</TD>
<td width="50">
<h3><A href="index.html"><IMG height="45" alt="Boost.Regex Index" src="uarrow.gif" width="43" border="0"></A></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<H3>Contents</H3>
<p></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" 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">regex_iterator</h2>
</td>
<td width="50">
<h3><a href="index.html"><img height="45" alt="Boost.Regex Index" src="uarrow.gif" width="43" border="0"></a></h3>
</td>
</tr>
</table>
<br>
<br>
<hr>
<h3>Contents</h3>
<dl class="index">
<dt><A href="#synopsis">Synopsis</A> <dt><a href="#description">Description</a> <dt><A href="#examples">
Examples</A></dt></dl>
<H3><A name="synopsis"></A>Synopsis</H3>
<P>The iterator type regex_iterator will enumerate all of the regular expression
<dt><a href="#synopsis">Synopsis</a> <dt><a href="#description">Description</a> <dt><a href="#examples">
Examples</a></dt>
</dl>
<h3><a name="synopsis"></a>Synopsis</h3>
<p>The iterator type regex_iterator will enumerate all of the regular expression
matches found in some sequence: dereferencing a regex_iterator yields a
reference to a&nbsp;<A href="match_results.html">match_results</A> object.</P>
<PRE>
reference to a&nbsp;<a href="match_results.html">match_results</a> object.</p>
<pre>
template &lt;class BidirectionalIterator,
class charT = iterator_traits&lt;BidirectionalIterator&gt;::value_type,
class traits = regex_traits&lt;charT&gt;,
@ -59,310 +63,365 @@ public:
regex_iterator operator++(int);
};
</PRE>
<H3><A name="description"></A>Description</H3>
<P>A regex_iterator is constructed from a pair of iterators, and enumerates all
occurrences of a regular expression within that iterator range.</P>
<PRE>regex_iterator();</PRE>
<B>
<P>
Effects:</B> constructs an end of sequence regex_iterator.</P><PRE>regex_iterator(BidirectionalIterator a, BidirectionalIterator b,
</pre>
<h3><a name="description"></a>Description</h3>
<p>A regex_iterator is constructed from a pair of iterators, and enumerates all
occurrences of a regular expression within that iterator range.</p>
<pre>
regex_iterator();
</pre>
<b></b>
<p><b>Effects:</b> constructs an end of sequence regex_iterator.</p>
<pre>
regex_iterator(BidirectionalIterator a, BidirectionalIterator b,
const regex_type&amp; re,
match_flag_type m = match_default);</PRE>
<B>
<P>
Effects: </B>constructs a regex_iterator that will enumerate all occurrences
of the expression <EM>re</EM>, within the sequence <EM>[a,b)</EM>, and found
using match flags <EM>m</EM>.&nbsp; The object <EM>re </EM>must exist for the
lifetime of the regex_iterator.</P><PRE>regex_iterator(const regex_iterator&amp; that);</PRE>
<B>
<P>
Effects: </B>constructs a copy of <CODE>that</CODE>.</P><B>
<P>
Postconditions:</B> <CODE>*this == that</CODE>.</P><PRE>regex_iterator&amp; operator=(const regex_iterator&amp;);</PRE>
<B>
<P>
Effects: </B>sets&nbsp;<CODE>*this</CODE> equal to those in <CODE>that</CODE>.</P><B>
<P>
Postconditions:</B> <CODE>*this == that</CODE>.</P><PRE>bool operator==(const regex_iterator&amp; that);</PRE>
<B>
<P>
Effects: </B>returns true if *this is equal to that.</P><PRE>bool operator!=(const regex_iterator&amp;);</PRE>
<B>
<P>
Effects: </B>returns <CODE>!(*this == that)</CODE>.</P>
<H5>RE.8.1.1 regex_iterator dereference</H5>
<PRE>const value_type&amp; operator*();</PRE>
<P>
<B>Effects:</B> dereferencing a regex_iterator object <EM>it</EM> yields a
const reference to a <A href="match_results.html">match_results</A> object,
whose members are set as follows:</P>
<P>
<TABLE id="Table2" cellSpacing="1" cellPadding="7" width="624" border="1">
<TBODY>
<TR>
<TD vAlign="top" width="50%"><B>
<P>
Element</B>
</P>
</TD>
<TD vAlign="top" width="50%"><B>
<P>
Value</B> </P></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>(*it).size()</P>
</TD>
<TD vAlign="top" width="50%">
<P>re.mark_count()</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>(*it).empty()</P>
</TD>
<TD vAlign="top" width="50%">
<P>false</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>(*it).prefix().first</P>
</TD>
<TD vAlign="top" width="50%">
<P>The end of the last match found, or the start of the underlying sequence if
this is the first match enumerated</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>(*it).prefix().last</P>
</TD>
<TD vAlign="top" width="50%">
<P>(*it)[0].first</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>(*it).prefix().matched</P>
</TD>
<TD vAlign="top" width="50%">
<P>(*it).prefix().first != (*it).prefix().second</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>(*it).suffix().first</P>
</TD>
<TD vAlign="top" width="50%">
<P>(*it)[0].second</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>(*it).suffix().last</P>
</TD>
<TD vAlign="top" width="50%">
<P>The end of the underlying sequence.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>(*it).suffix().matched</P>
</TD>
<TD vAlign="top" width="50%">
<P>(*it).suffix().first != (*it).suffix().second</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>(*it)[0].first</P>
</TD>
<TD vAlign="top" width="50%">
<P>The start of the sequence of characters that matched the regular expression</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>(*it)[0].second</P>
</TD>
<TD vAlign="top" width="50%">
<P>The end of the sequence of characters that matched the regular expression</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>(*it)[0].matched</P>
</TD>
<TD vAlign="top" width="50%">
<P>
<CODE>true</CODE> if a full match was found, and <CODE>false</CODE> if it was a
partial match (found as a result of the <CODE>match_partial</CODE> flag being
set).</P></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>(*it)[n].first</P>
</TD>
<TD vAlign="top" width="50%">
<P>For all integers n &lt; (*it).size(), the start of the sequence that matched
sub-expression <I>n</I>. Alternatively, if sub-expression n did not participate
in the match, then <I>last</I>.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>(*it)[n].second</P>
</TD>
<TD vAlign="top" width="50%">
<P>For all integers n &lt; (*it).size(), the end of the sequence that matched
sub-expression <I>n</I>. Alternatively, if sub-expression n did not participate
in the match, then <I>last</I>.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>(*it)[n].matched</P>
</TD>
<TD vAlign="top" width="50%">
<P>For all integers n &lt; (*it).size(), true if sub-expression <I>n</I> participated
in the match, false otherwise.</P>
</TD>
<TR>
<TD vAlign="top" width="50%">(*it).position(n)</TD>
<TD vAlign="top" width="50%">For all integers n &lt; (*it).size(), then the
distance from the start of the underlying sequence to the start of
sub-expression match <EM>n</EM>.</TD>
</TR>
</TBODY></TD></TR></TABLE></P><PRE>const value_type* operator-&gt;();</PRE>
<B>
<P>
Effects: </B>returns <CODE>&amp;(*this)</CODE>.</P><PRE>regex_iterator&amp; operator++();</PRE>
<P><STRONG>Effects:</STRONG> moves the iterator to the next match in the
match_flag_type m = match_default);
</pre>
<b></b>
<p><b>Effects:</b> constructs a regex_iterator that will enumerate all occurrences
of the expression <em>re</em>, within the sequence <em>[a,b)</em>, and found
using match flags <em>m</em>.&nbsp; The object <em>re</em> must exist for the
lifetime of the regex_iterator.</p>
<P><STRONG>Throws:</STRONG> <CODE>std::runtime_error</CODE> if the complexity of
matching the expression against an N character string begins to exceed O(N<SUP>2</SUP>),
or if the program runs out of stack space while matching the expression (if
Boost.regex is <A href="configuration.html">configured</A> in recursive mode),
or if the matcher exhausts it's permitted memory allocation (if Boost.regex is <A href="configuration.html">
configured</A> in non-recursive mode).</P>
<pre>
regex_iterator(const regex_iterator&amp; that);
</pre>
<b></b>
<p><b>Effects:</b> constructs a copy of <code>that</code>.</p>
<b></b>
<p><b>Postconditions:</b> <code>*this == that</code>.</p>
<pre>
regex_iterator&amp; operator=(const regex_iterator&amp;);
</pre>
<b></b>
<p><b>Effects:</b> sets&nbsp;<code>*this</code> equal to those in <code>that</code>.</p>
<b></b>
<p><b>Postconditions:</b> <code>*this == that</code>.</p>
<pre>
bool operator==(const regex_iterator&amp; that);
</pre>
<b></b>
<p><b>Effects:</b> returns true if *this is equal to that.</p>
<pre>
bool operator!=(const regex_iterator&amp;);
</pre>
<b></b>
<p><b>Effects:</b> returns <code>!(*this == that)</code>.</p>
<pre>
const value_type&amp; operator*();
</pre>
<p><b>Effects:</b> dereferencing a regex_iterator object <em>it</em> yields a
const reference to a <a href="match_results.html">match_results</a> object,
whose members are set as follows:</p>
<p></p>
<table id="Table2" cellspacing="1" cellpadding="7" width="624" border="1">
<tbody>
<tr>
<td valign="top" width="50%"><b></b>
<p><b>Element</b></p>
</td>
<td valign="top" width="50%"><b></b>
<p><b>Value</b></p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>(*it).size()</p>
</td>
<td valign="top" width="50%">
<p>re.mark_count()</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>(*it).empty()</p>
</td>
<td valign="top" width="50%">
<p>false</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>(*it).prefix().first</p>
</td>
<td valign="top" width="50%">
<p>The end of the last match found, or the start of the underlying sequence if
this is the first match enumerated</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>(*it).prefix().last</p>
</td>
<td valign="top" width="50%">
<p>(*it)[0].first</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>(*it).prefix().matched</p>
</td>
<td valign="top" width="50%">
<p>(*it).prefix().first != (*it).prefix().second</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>(*it).suffix().first</p>
</td>
<td valign="top" width="50%">
<p>(*it)[0].second</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>(*it).suffix().last</p>
</td>
<td valign="top" width="50%">
<p>The end of the underlying sequence.</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>(*it).suffix().matched</p>
</td>
<td valign="top" width="50%">
<p>(*it).suffix().first != (*it).suffix().second</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>(*it)[0].first</p>
</td>
<td valign="top" width="50%">
<p>The start of the sequence of characters that matched the regular expression</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>(*it)[0].second</p>
</td>
<td valign="top" width="50%">
<p>The end of the sequence of characters that matched the regular expression</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>(*it)[0].matched</p>
</td>
<td valign="top" width="50%">
<p><code>true</code> if a full match was found, and <code>false</code> if it was a
partial match (found as a result of the <code>match_partial</code> flag being
set).</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>(*it)[n].first</p>
</td>
<td valign="top" width="50%">
<p>For all integers n &lt; (*it).size(), the start of the sequence that matched
sub-expression <i>n</i>. Alternatively, if sub-expression n did not participate
in the match, then <i>last</i>.</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>(*it)[n].second</p>
</td>
<td valign="top" width="50%">
<p>For all integers n &lt; (*it).size(), the end of the sequence that matched
sub-expression <i>n</i>. Alternatively, if sub-expression n did not participate
in the match, then <i>last</i>.</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>(*it)[n].matched</p>
</td>
<td valign="top" width="50%">
<p>For all integers n &lt; (*it).size(), true if sub-expression <i>n</i> participated
in the match, false otherwise.</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">(*it).position(n)</td>
<td valign="top" width="50%">For all integers n &lt; (*it).size(), then the
distance from the start of the underlying sequence to the start of
sub-expression match <em>n</em>.</td>
</tr>
</tbody>
</table>
<br>
<br>
<pre>
const value_type* operator-&gt;();
</pre>
<b></b>
<p><b>Effects:</b> returns <code>&amp;(*this)</code>.</p>
<pre>
regex_iterator&amp; operator++();
</pre>
<p><strong>Effects:</strong> moves the iterator to the next match in the
underlying sequence, or the end of sequence iterator if none if found.
&nbsp;When the last match found matched a zero length string, then the
regex_iterator will find the next match as follows: if there exists a non-zero
length match that starts at the same location as the last one, then returns it,
otherwise starts looking for the next (possibly zero length) match from one
position to the right of the last match.</P>
<B>
<P>
Returns:</B> <CODE>*this</CODE>.</P><PRE>regex_iterator operator++(int);</PRE>
<B>
<P>
Effects:</B> constructs a copy <CODE>result</CODE> of <CODE>*this</CODE>,
then calls <CODE>++(*this)</CODE>.</P><B>
<P>
Returns:</B> <CODE>result</CODE>.</P>
<H3>Examples</H3>
<P>The following <A href="../example/snippets/regex_iterator_example.cpp">example</A>
takes a C++ source file and builds up an index of class names, and the location
of that class in the file.</P>
position to the right of the last match.</p>
<P><STRONG>Throws:</STRONG> <CODE>std::runtime_error</CODE> if the complexity of
matching the expression against an N character string begins to exceed O(N<SUP>2</SUP>),
or if the program runs out of stack space while matching the expression (if
Boost.regex is <A href="configuration.html">configured</A> in recursive mode),
or if the matcher exhausts it's permitted memory allocation (if Boost.regex is <A href="configuration.html">
configured</A> in non-recursive mode).</P>
<b></b>
<p><b>Returns:</b> <code>*this</code>.</p>
<pre>
<FONT color=#008040>#include &lt;string&gt;</FONT>
<FONT color=#008040>#include &lt;map&gt;</FONT>
<FONT color=#008040>#include &lt;fstream&gt;</FONT>
<FONT color=#008040>#include &lt;iostream&gt;</FONT>
<FONT color=#008040>#include &lt;boost/regex.hpp&gt;</FONT>
regex_iterator operator++(int);
</pre>
<b></b>
<p><b>Effects:</b> constructs a copy <code>result</code> of <code>*this</code>,
then calls <code>++(*this)</code>.</p>
<b></b>
<p><b>Returns:</b> <code>result</code>.</p>
<h3>Examples</h3>
<p>The following <a href="../example/snippets/regex_iterator_example.cpp">example</a>
takes a C++ source file and builds up an index of class names, and the location
of that class in the file.</p>
<pre>
<font color="#008040">#include &lt;string&gt;</font>
<font color="#008040">#include &lt;map&gt;</font>
<font color="#008040">#include &lt;fstream&gt;</font>
<font color="#008040">#include &lt;iostream&gt;</font>
<font color="#008040">#include &lt;boost/regex.hpp&gt;</font>
<B>using</B> <B>namespace</B> std;
<b>using</b> <b>namespace</b> std;
<I><FONT color=#000080>// purpose:</FONT></I>
<I><FONT color=#000080>// takes the contents of a file in the form of a string</FONT></I>
<I><FONT color=#000080>// and searches for all the C++ class definitions, storing</FONT></I>
<I><FONT color=#000080>// their locations in a map of strings/int's</FONT></I>
<i><font color="#000080">// purpose:</font></i>
<i><font color=
#000080>// takes the contents of a file in the form of a string</font></i>
<i><font color=
#000080>// and searches for all the C++ class definitions, storing</font></i>
<i><font color=
#000080>// their locations in a map of strings/int's</font></i>
<B>typedef</B> std::map&lt;std::string, std::string::difference_type, std::less&lt;std::string&gt; &gt; map_type;
<b>typedef</b> std::map&lt;std::string, std::string::difference_type, std::less&lt;std::string&gt; &gt; map_type;
<B>const</B> <B>char</B>* re =
<I><FONT color=#000080>// possibly leading whitespace: </FONT></I>
<FONT color=#0000ff>"^[[:space:]]*"</FONT>
<I><FONT color=#000080>// possible template declaration:</FONT></I>
<FONT color=#0000ff>"(template[[:space:]]*&lt;[^;:{]+&gt;[[:space:]]*)?"</FONT>
<I><FONT color=#000080>// class or struct:</FONT></I>
<FONT color=#0000ff>"(class|struct)[[:space:]]*"</FONT>
<I><FONT color=#000080>// leading declspec macros etc:</FONT></I>
<FONT color=#0000ff>"("</FONT>
<FONT color=#0000ff>"\\&lt;\\w+\\&gt;"</FONT>
<FONT color=#0000ff>"("</FONT>
<FONT color=#0000ff>"[[:blank:]]*\\([^)]*\\)"</FONT>
<FONT color=#0000ff>")?"</FONT>
<FONT color=#0000ff>"[[:space:]]*"</FONT>
<FONT color=#0000ff>")*"</FONT>
<I><FONT color=#000080>// the class name</FONT></I>
<FONT color=#0000ff>"(\\&lt;\\w*\\&gt;)[[:space:]]*"</FONT>
<I><FONT color=#000080>// template specialisation parameters</FONT></I>
<FONT color=#0000ff>"(&lt;[^;:{]+&gt;)?[[:space:]]*"</FONT>
<I><FONT color=#000080>// terminate in { or :</FONT></I>
<FONT color=#0000ff>"(\\{|:[^;\\{()]*\\{)"</FONT>;
<b>const</b> <b>char</b>* re =
<i><font color=
#000080>// possibly leading whitespace: </font></i>
<font color="#0000ff">"^[[:space:]]*"</font>
<i><font color=
#000080>// possible template declaration:</font></i>
<font color=
#0000ff>"(template[[:space:]]*&lt;[^;:{]+&gt;[[:space:]]*)?"</font>
<i><font color="#000080">// class or struct:</font></i>
<font color="#0000ff">"(class|struct)[[:space:]]*"</font>
<i><font color=
#000080>// leading declspec macros etc:</font></i>
<font color="#0000ff">"("</font>
<font color="#0000ff">"\\&lt;\\w+\\&gt;"</font>
<font color="#0000ff">"("</font>
<font color="#0000ff">"[[:blank:]]*\\([^)]*\\)"</font>
<font color="#0000ff">")?"</font>
<font color="#0000ff">"[[:space:]]*"</font>
<font color="#0000ff">")*"</font>
<i><font color="#000080">// the class name</font></i>
<font color="#0000ff">"(\\&lt;\\w*\\&gt;)[[:space:]]*"</font>
<i><font color=
#000080>// template specialisation parameters</font></i>
<font color="#0000ff">"(&lt;[^;:{]+&gt;)?[[:space:]]*"</font>
<i><font color="#000080">// terminate in { or :</font></i>
<font color="#0000ff">"(\\{|:[^;\\{()]*\\{)"</font>;
boost::regex expression(re);
map_type class_index;
<B>bool</B> regex_callback(<B>const</B> boost::match_results&lt;std::string::const_iterator&gt;&amp; what)
<b>bool</b> regex_callback(<b>const</b> boost::match_results&lt;std::string::const_iterator&gt;&amp; what)
{
<I><FONT color=#000080>// what[0] contains the whole string</FONT></I>
<I><FONT color=#000080>// what[5] contains the class name.</FONT></I>
<I><FONT color=#000080>// what[6] contains the template specialisation if any.</FONT></I>
<I><FONT color=#000080>// add class name and position to map:</FONT></I>
class_index[what[<FONT color=#0000a0>5</FONT>].str() + what[<FONT color=#0000a0>6</FONT>].str()] = what.position(<FONT color=#0000a0>5</FONT>);
<B>return</B> <B>true</B>;
<i><font color=
#000080>// what[0] contains the whole string</font></i>
<i><font color=
#000080>// what[5] contains the class name.</font></i>
<i><font color=
#000080>// what[6] contains the template specialisation if any.</font></i>
<i><font color=
#000080>// add class name and position to map:</font></i>
class_index[what[<font color=
#0000a0>5</font>].str() + what[<font color=
#0000a0>6</font>].str()] = what.position(<font color=
#0000a0>5</font>);
<b>return</b> <b>true</b>;
}
<B>void</B> load_file(std::string&amp; s, std::istream&amp; is)
<b>void</b> load_file(std::string&amp; s, std::istream&amp; is)
{
s.erase();
s.reserve(is.rdbuf()-&gt;in_avail());
<B>char</B> c;
<B>while</B>(is.get(c))
<b>char</b> c;
<b>while</b>(is.get(c))
{
<B>if</B>(s.capacity() == s.size())
s.reserve(s.capacity() * <FONT color=#0000a0>3</FONT>);
s.append(<FONT color=#0000a0>1</FONT>, c);
<b>if</b>(s.capacity() == s.size())
s.reserve(s.capacity() * <font color="#0000a0">3</font>);
s.append(<font color="#0000a0">1</font>, c);
}
}
<B>int</B> main(<B>int</B> argc, <B>const</B> <B>char</B>** argv)
<b>int</b> main(<b>int</b> argc, <b>const</b> <b>char</b>** argv)
{
std::string text;
<B>for</B>(<B>int</B> i = <FONT color=#0000a0>1</FONT>; i &lt; argc; ++i)
<b>for</b>(<b>int</b> i = <font color=
#0000a0>1</font>; i &lt; argc; ++i)
{
cout &lt;&lt; <FONT color=#0000ff>"Processing file "</FONT> &lt;&lt; argv[i] &lt;&lt; endl;
cout &lt;&lt; <font color=
#0000ff>"Processing file "</font> &lt;&lt; argv[i] &lt;&lt; endl;
std::ifstream fs(argv[i]);
load_file(text, fs);
<I><FONT color=#000080>// construct our iterators:</FONT></I>
<i><font color=
#000080>// construct our iterators:</font></i>
boost::regex_iterator&lt;std::string::const_iterator&gt; m1(text.begin(), text.end(), expression);
boost::regex_iterator&lt;std::string::const_iterator&gt; m2;
std::for_each(m1, m2, <20>ex_callback);
<I><FONT color=#000080>// copy results:</FONT></I>
cout &lt;&lt; class_index.size() &lt;&lt; <FONT color=#0000ff>" matches found"</FONT> &lt;&lt; endl;
<i><font color="#000080">// copy results:</font></i>
cout &lt;&lt; class_index.size() &lt;&lt; <font color=
#0000ff>" matches found"</font> &lt;&lt; endl;
map_type::iterator c, d;
c = class_index.begin();
d = class_index.end();
<B>while</B>(c != d)
<b>while</b>(c != d)
{
cout &lt;&lt; <FONT color=#0000ff>"class \""</FONT> &lt;&lt; (*c).first &lt;&lt; <FONT color=#0000ff>"\" found at index: "</FONT> &lt;&lt; (*c).second &lt;&lt; endl;
cout &lt;&lt; <font color=
#0000ff>"class \""</font> &lt;&lt; (*c).first &lt;&lt; <font
color=
#0000ff>"\" found at index: "</font> &lt;&lt; (*c).second &lt;&lt; endl;
++c;
}
class_index.erase(class_index.begin(), class_index.end());
}
<B>return</B> <FONT color=#0000a0>0</FONT>;
<b>return</b> <font color="#0000a0">0</font>;
}
</pre>
<HR>
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
<p><i><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
<p align="left"><i>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
for any purpose. It is provided "as is" without express or implied warranty.</i></p>
</body>
</html>

View File

@ -26,17 +26,16 @@
<p></p>
<H3>Contents</H3>
<dl class="index">
<dt><a href="#synopsis">Synopsis</a></dt>
<dt><a href="#description">Description</a></dt>
<dt><a href="#examples">Examples</a></dt>
<dt><a href="#synopsis">Synopsis</a> <dt><a href="#description">Description</a> <dt><a href="#examples">
Examples</a></dt>
</dl>
<H3><A name="synopsis"></A>Synopsis</H3>
<PRE><A name=query_match></A>#include &lt;<A href="../../boost/regex.hpp">boost/regex.hpp</A>&gt; </PRE>
<P>The algorithm regex _match determines whether a given regular expression
matches a given sequence denoted by a pair of bidirectional-iterators, the
algorithm is defined as follows, <EM><FONT color="red">note that the result is true
only if the expression matches the whole of the input sequence</FONT></EM>,
the main use of this function is data input validation.
algorithm is defined as follows, <STRONG>note that the result is true only if the
expression matches the whole of the input sequence</STRONG>, the main use of
this function is data input validation.
<PRE>template &lt;class BidirectionalIterator, class Allocator, class charT,
class traits, class Allocator2&gt;
bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
@ -47,7 +46,7 @@ bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
template &lt;class BidirectionalIterator, class charT, class traits, class Allocator2&gt;
bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</a> flags = match_default);
<A href="match_flag_type.html">match_flag_type</A> flags = match_default);
template &lt;class charT, class Allocator, class traits, class Allocator2&gt;
bool regex_match(const charT* str, <A href="match_results.html">match_results</A>&lt;const charT*, Allocator&gt;&amp; m,
@ -78,201 +77,194 @@ bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
<A href="match_results.html">match_results</A>&lt;BidirectionalIterator, Allocator&gt;&amp; m,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</A> flags = match_default);</PRE>
<B>
<P>
Requires:</B> Type BidirectionalIterator meets the requirements of a
<P><B> Requires:</B> Type BidirectionalIterator meets the requirements of a
Bidirectional Iterator (24.1.4).</P>
<B>
<P>
Effects: </B>Determines whether there is an exact match between the regular
expression <I>e</I>, and all of the character sequence [first, last), parameter <I>
flags</I> is used to <A href="match_flag_type.html">control how the expression
is matched</A> against the character sequence. Returns true if such a match
exists, false otherwise.</P><B>
<P>
Postconditions: </B>If the function returns false, then the effect on
parameter <I>m</I> is undefined, otherwise the effects on parameter <I>m</I> are
given in the table:</P> <I>
<P>
<DIV align="center">
<P></P>
</I>
<P><B> Effects: </B>Determines whether there is an exact match between the regular
expression <I>e</I>, and all of the character sequence [first, last), parameter <I>
flags</I> is used to <A href="match_flag_type.html">control how the expression
is matched</A> against the character sequence. Returns true if such a match
exists, false otherwise.</P>
<P><STRONG>Throws:</STRONG> <code>std::runtime_error</code> if the complexity of matching the
expression against an N character string begins to exceed O(N<SUP>2</SUP>), or
if the program runs out of stack space while matching the expression (if
Boost.regex is <A href="configuration.html">configured</A> in recursive mode),
or if the matcher exhausts it's permitted memory allocation (if Boost.regex is <A href="configuration.html">
configured</A> in non-recursive mode).</P>
<P><B> Postconditions: </B>If the function returns false, then the effect on
parameter <I>m</I> is undefined, otherwise the effects on parameter <I>m</I> are
given in the table:</P>
<P align="center">
<CENTER>
<TABLE id="Table2" cellSpacing="1" cellPadding="7" width="624" border="1">
<TBODY>
<TR>
<TD vAlign="top" width="50%"><B>
<P>
Element</B>
</P>
</TD>
<TD vAlign="top" width="50%"><B>
<P>
Value</B> </P></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.size()</P>
</TD>
<TD vAlign="top" width="50%">
<P>e.mark_count()</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.empty()</P>
</TD>
<TD vAlign="top" width="50%">
<P>false</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.prefix().first</P>
</TD>
<TD vAlign="top" width="50%">
<P>first</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.prefix().last</P>
</TD>
<TD vAlign="top" width="50%">
<P>first</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.prefix().matched</P>
</TD>
<TD vAlign="top" width="50%">
<P>false</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.suffix().first</P>
</TD>
<TD vAlign="top" width="50%">
<P>last</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.suffix().last</P>
</TD>
<TD vAlign="top" width="50%">
<P>last</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.suffix().matched</P>
</TD>
<TD vAlign="top" width="50%">
<P>false</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[0].first</P>
</TD>
<TD vAlign="top" width="50%">
<P>first</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[0].second</P>
</TD>
<TD vAlign="top" width="50%">
<P>last</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[0].matched</P>
</TD>
<TD vAlign="top" width="50%"><CODE>
<P>
true</CODE> if a full match was found, and <CODE>false</CODE> if it was a
partial match (found as a result of the <CODE>match_partial</CODE> flag being
set).</P></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[n].first</P>
</TD>
<TD vAlign="top" width="50%">
<P>For all integers n &lt; m.size(), the start of the sequence that matched
sub-expression <I>n</I>. Alternatively, if sub-expression n did not participate
in the match, then <I>last</I>.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[n].second</P>
</TD>
<TD vAlign="top" width="50%">
<P>For all integers n &lt; m.size(), the end of the sequence that matched
sub-expression <I>n</I>. Alternatively, if sub-expression n did not participate
in the match, then <I>last</I>.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[n].matched</P>
</TD>
<TD vAlign="top" width="50%">
<P>For all integers n &lt; m.size(), true if sub-expression <I>n</I> participated
in the match, false otherwise.</P>
<P></P>
</TD>
</TR>
</TBODY></TD></TR></TABLE></CENTER>
<TD vAlign="top" width="50%">
<P><B> Element</B>
</P>
</TD>
<TD vAlign="top" width="50%">
<P><B> Value</B>
</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.size()</P>
</TD>
<TD vAlign="top" width="50%">
<P>e.mark_count()</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.empty()</P>
</TD>
<TD vAlign="top" width="50%">
<P>false</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.prefix().first</P>
</TD>
<TD vAlign="top" width="50%">
<P>first</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.prefix().last</P>
</TD>
<TD vAlign="top" width="50%">
<P>first</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.prefix().matched</P>
</TD>
<TD vAlign="top" width="50%">
<P>false</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.suffix().first</P>
</TD>
<TD vAlign="top" width="50%">
<P>last</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.suffix().last</P>
</TD>
<TD vAlign="top" width="50%">
<P>last</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.suffix().matched</P>
</TD>
<TD vAlign="top" width="50%">
<P>false</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[0].first</P>
</TD>
<TD vAlign="top" width="50%">
<P>first</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[0].second</P>
</TD>
<TD vAlign="top" width="50%">
<P>last</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[0].matched</P>
</TD>
<TD vAlign="top" width="50%">
<P><CODE> true</CODE> if a full match was found, and <CODE>false</CODE> if it was
a partial match (found as a result of the <CODE>match_partial</CODE> flag being
set).</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[n].first</P>
</TD>
<TD vAlign="top" width="50%">
<P>For all integers n &lt; m.size(), the start of the sequence that matched
sub-expression <I>n</I>. Alternatively, if sub-expression n did not participate
in the match, then <I>last</I>.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[n].second</P>
</TD>
<TD vAlign="top" width="50%">
<P>For all integers n &lt; m.size(), the end of the sequence that matched
sub-expression <I>n</I>. Alternatively, if sub-expression n did not participate
in the match, then <I>last</I>.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[n].matched</P>
</TD>
<TD vAlign="top" width="50%">
<P>For all integers n &lt; m.size(), true if sub-expression <I>n</I> participated
in the match, false otherwise.</P>
</TD>
</TR>
</TBODY></TD></TR></TABLE>
</CENTER>
<P></P>
</DIV><PRE>template &lt;class BidirectionalIterator, class charT, class traits, class Allocator2&gt;
<DIV></DIV>
<PRE>&nbsp;</PRE>
<PRE>template &lt;class BidirectionalIterator, class charT, class traits, class Allocator2&gt;
bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</A> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Behaves "as if" by constructing an instance of <CODE><A href="match_results.html">
match_results</A>&lt;</CODE>BidirectionalIterator<CODE>&gt; what</CODE>,
and then returning the result of <CODE>regex_match(first, last, what, e, flags)</CODE>.</P><PRE>template &lt;class charT, class Allocator, class traits, class Allocator2&gt;
<P><B> Effects:</B> Behaves "as if" by constructing an instance of <CODE><A href="match_results.html">
match_results</A>&lt;</CODE>BidirectionalIterator<CODE>&gt; what</CODE>,
and then returning the result of <CODE>regex_match(first, last, what, e, flags)</CODE>.</P>
<PRE>template &lt;class charT, class Allocator, class traits, class Allocator2&gt;
bool regex_match(const charT* str, <A href="match_results.html">match_results</A>&lt;const charT*, Allocator&gt;&amp; m,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</A> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>regex_match(str, str +
char_traits&lt;charT&gt;::length(str), m, e, flags)</CODE>.</P><PRE>template &lt;class ST, class SA, class Allocator, class charT,
<P><B> Effects:</B> Returns the result of <CODE>regex_match(str, str +
char_traits&lt;charT&gt;::length(str), m, e, flags)</CODE>.</P>
<PRE>template &lt;class ST, class SA, class Allocator, class charT,
class traits, class Allocator2&gt;
bool regex_match(const basic_string&lt;charT, ST, SA&gt;&amp; s,
<A href="match_results.html">match_results</A>&lt;typename basic_string&lt;charT, ST, SA&gt;::const_iterator, Allocator&gt;&amp; m,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</A> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>regex_match(s.begin(), s.end(), m, e,
flags)</CODE>.</P><PRE>template &lt;class charT, class traits, class Allocator2&gt;
<P><B> Effects:</B> Returns the result of <CODE>regex_match(s.begin(), s.end(), m, e,
flags)</CODE>.</P>
<PRE>template &lt;class charT, class traits, class Allocator2&gt;
bool regex_match(const charT* str,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</A> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>regex_match(str, str +
char_traits&lt;charT&gt;::length(str), e, flags)</CODE>.</P><PRE>template &lt;class ST, class SA, class charT, class traits, class Allocator2&gt;
<P><B> Effects:</B> Returns the result of <CODE>regex_match(str, str +
char_traits&lt;charT&gt;::length(str), e, flags)</CODE>.</P>
<PRE>template &lt;class ST, class SA, class charT, class traits, class Allocator2&gt;
bool regex_match(const basic_string&lt;charT, ST, SA&gt;&amp; s,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</A> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>regex_match(s.begin(), s.end(), e,
flags)</CODE>.
<H3><A name="examples"></A>Examples</H3>
<P><B> Effects:</B> Returns the result of <CODE>regex_match(s.begin(), s.end(), e,
flags)</CODE>.
<H3><A name="examples"></A>Examples</H3>
<P>The following <A href="../example/snippets/regex_match_example.cpp">example</A>
processes an ftp response:
<P></P>
@ -311,7 +303,7 @@ regex expression(<FONT color=#000080>"([0-9]+)(\\-| |$)(.*)"</FONT>);
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>

View File

@ -25,17 +25,17 @@
<HR>
<p></p>
<P>Algorithm regex_merge has been renamed <A href="regex_replace.html">regex_replace</A>,
existing code will continue to compile, but newcode should use <A href="regex_replace.html">
existing code will continue to compile, but new code should use <A href="regex_replace.html">
regex_replace</A> instead.</P>
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
@ -44,3 +44,4 @@
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -34,7 +34,7 @@
output iterator. Sections of text that do not match are copied to the output
unchanged only if the <EM>flags</EM> parameter does not have the flag <A href="match_flags.html">
format_no_copy</A> set. If the flag <A href="match_flags.html">format_first_only</A>
is set then only the first occurance is replaced rather than all
is set then only the first occurrence is replaced rather than all
occurrences.&nbsp;<PRE>template &lt;class OutputIterator, class BidirectionalIterator, class traits,
class Allocator, class charT&gt;
OutputIterator regex_replace(OutputIterator out,
@ -60,9 +60,7 @@ OutputIterator regex_replace(OutputIterator out,
const basic_regex&lt;charT, traits, Allocator&gt;&amp; e,
const basic_string&lt;charT&gt;&amp; fmt,
match_flag_type flags = match_default);</PRE>
<B>
<P>
Effects:</B> Finds all the non-overlapping matches <I>m</I> of type <CODE>match_results&lt;BidirectionalIterator&gt;
<P><B> Effects:</B> Finds all the non-overlapping matches <I>m</I> of type <CODE>match_results&lt;BidirectionalIterator&gt;
</CODE>that occur within the sequence [first, last). If no such matches are
found and <CODE>!(flags &amp; format_no_copy)</CODE> then calls <CODE>std::copy(first,
last, out)</CODE>. Otherwise, for each match found, if <CODE>!(flags &amp;
@ -72,19 +70,23 @@ OutputIterator regex_replace(OutputIterator out,
last_m,suffix().last, out) </CODE>where <CODE>last_m</CODE> is a copy of the
last match found. If <CODE>flags &amp; format_first_only</CODE> is non-zero
then only the first match found is replaced.</P>
<B>
<P>
Returns:</B> <CODE>out</CODE>. </P><PRE>template &lt;class traits, class Allocator, class charT&gt;
<P><STRONG>Throws:</STRONG> <CODE>std::runtime_error</CODE> if the complexity of
matching the expression against an N character string begins to exceed O(N<SUP>2</SUP>),
or if the program runs out of stack space while matching the expression (if
Boost.regex is <A href="configuration.html">configured</A> in recursive mode),
or if the matcher exhausts it's permitted memory allocation (if Boost.regex is <A href="configuration.html">
configured</A> in non-recursive mode).</P>
<P><B> Returns:</B> <CODE>out</CODE>.
</P>
<PRE>template &lt;class traits, class Allocator, class charT&gt;
basic_string&lt;charT&gt; regex_replace(const basic_string&lt;charT&gt;&amp; s,
const basic_regex&lt;charT, traits, Allocator&gt;&amp; e,
const basic_string&lt;charT&gt;&amp; fmt,
match_flag_type flags = match_default);</PRE>
<B>
<P>
Effects:</B> Constructs an object <CODE>basic_string&lt;charT&gt; result</CODE>,
calls <CODE>regex_replace(back_inserter(result), s.begin(), s.end(), e, fmt,
flags)</CODE>, and then returns <CODE>result</CODE>.
<H3><A name="examples"></A>Examples</H3>
<P><B> Effects:</B> Constructs an object <CODE>basic_string&lt;charT&gt; result</CODE>,
calls <CODE>regex_replace(back_inserter(result), s.begin(), s.end(), e, fmt,
flags)</CODE>, and then returns <CODE>result</CODE>.
<H3><A name="examples"></A>Examples</H3>
<P>The following <A href="../example/snippets/regex_replace_example.cpp">example</A>
takes C/C++ source code as input, and outputs syntax highlighted HTML code.</P>
<P></P>
@ -193,10 +195,11 @@ boost::regex e1, e2;
</FONT> <FONT color=#0000ff>"&lt;P&gt; &lt;/P&gt;\n&lt;PRE&gt;"</FONT>;
<B>const</B> <B>char</B>* footer_text = <FONT color=#0000ff>"&lt;/PRE&gt;\n&lt;/BODY&gt;\n\n"</FONT>;
<HR></PRE>
</PRE>
<HR>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>

View File

@ -38,77 +38,79 @@
class Allocator, class charT,
class traits, class Allocator2&gt;
bool regex_search(BidirectionalIterator first, BidirectionalIterator last,
<a href=match_results.html>match_results</a>&lt;BidirectionalIterator, Allocator&gt;&amp; m,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator2&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);
<a href="match_results.html">match_results</a>&lt;BidirectionalIterator, Allocator&gt;&amp; m,
const <a href="basic_regex.html">basic_regex</a>&lt;charT, traits, Allocator2&gt;&amp; e,
<a href="match_flag_type.html">match_flag_type</a> flags = match_default);
template &lt;class ST, class SA,
class Allocator, class charT,
class traits, class Allocator2&gt;
bool regex_search(const basic_string&lt;charT, ST, SA&gt;&amp; s,
<a href=match_results.html>match_results</a>&lt;
<a href="match_results.html">match_results</a>&lt;
typename basic_string&lt;charT, ST,SA&gt;::const_iterator,
Allocator&gt;&amp; m,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator2&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);
const <a href="basic_regex.html">basic_regex</a>&lt;charT, traits, Allocator2&gt;&amp; e,
<a href="match_flag_type.html">match_flag_type</a> flags = match_default);
template&lt;class charT, class Allocator, class traits,
class Allocator2&gt;
bool regex_search(const charT* str,
<a href=match_results.html>match_results</a>&lt;const charT*, Allocator&gt;&amp; m,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator2&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);
<a href="match_results.html">match_results</a>&lt;const charT*, Allocator&gt;&amp; m,
const <a href="basic_regex.html">basic_regex</a>&lt;charT, traits, Allocator2&gt;&amp; e,
<a href="match_flag_type.html">match_flag_type</a> flags = match_default);
template &lt;class BidirectionalIterator, class Allocator,
class charT, class traits&gt;
bool regex_search(BidirectionalIterator first, BidirectionalIterator last,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);
const <a href="basic_regex.html">basic_regex</a>&lt;charT, traits, Allocator&gt;&amp; e,
<a href="match_flag_type.html">match_flag_type</a> flags = match_default);
template &lt;class charT, class Allocator,
class traits&gt;
bool regex_search(const charT* str,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);
const <a href="basic_regex.html">basic_regex</a>&lt;charT, traits, Allocator&gt;&amp; e,
<a href="match_flag_type.html">match_flag_type</a> flags = match_default);
template&lt;class ST, class SA,
class Allocator, class charT,
class traits&gt;
bool regex_search(const basic_string&lt;charT, ST, SA&gt;&amp; s,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);
const <a href="basic_regex.html">basic_regex</a>&lt;charT, traits, Allocator&gt;&amp; e,
<a href="match_flag_type.html">match_flag_type</a> flags = match_default);
</PRE>
<H3><A name="description"></A>Description</H3>
<PRE>template &lt;class BidirectionalIterator, class Allocator, class charT,
class traits, class Allocator2&gt;
bool regex_search(BidirectionalIterator first, BidirectionalIterator last,
<a href=match_results.html>match_results</a>&lt;BidirectionalIterator, Allocator&gt;&amp; m,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator2&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);</PRE>
<B>
<P>
Requires:</B> Type BidirectionalIterator meets the requirements of a
<a href="match_results.html">match_results</a>&lt;BidirectionalIterator, Allocator&gt;&amp; m,
const <a href="basic_regex.html">basic_regex</a>&lt;charT, traits, Allocator2&gt;&amp; e,
<a href="match_flag_type.html">match_flag_type</a> flags = match_default);</PRE>
<P><B> Requires:</B> Type BidirectionalIterator meets the requirements of a
Bidirectional Iterator (24.1.4).</P>
<B>
<P>
Effects: </B>Determines whether there is some sub-sequence within
[first,last) that matches the regular expression <I>e</I>, parameter <I>flags</I>
is used to control how the expression is matched against the character
sequence. Returns true if such a sequence exists, false otherwise.</P><B>
<P>
Postconditions: </B>If the function returns false, then the effect on
parameter <I>m</I> is undefined, otherwise the effects on parameter <I>m</I> are
given in the table:</P>
<P><B> Effects: </B>Determines whether there is some sub-sequence within
[first,last) that matches the regular expression <I>e</I>, parameter <I>flags</I>
is used to control how the expression is matched against the character
sequence. Returns true if such a sequence exists, false otherwise.</P>
<P><STRONG>Throws:</STRONG> <CODE>std::runtime_error</CODE> if the complexity of
matching the expression against an N character string begins to exceed O(N<SUP>2</SUP>),
or if the program runs out of stack space while matching the expression (if
Boost.regex is <A href="configuration.html">configured</A> in recursive mode),
or if the matcher exhausts it's permitted memory allocation (if Boost.regex is <A href="configuration.html">
configured</A> in non-recursive mode).</P>
<P><B> Postconditions: </B>If the function returns false, then the effect on
parameter <I>m</I> is undefined, otherwise the effects on parameter <I>m</I> are
given in the table:</P>
<DIV align="center">
<CENTER>
<TABLE id="Table2" cellSpacing="1" cellPadding="7" width="624" border="1">
<TR>
<TD vAlign="top" width="50%"><B>
<P>
Element</B></P></TD>
<TD vAlign="top" width="50%"><B>
<P>
Value</B> </P></TD>
<TD vAlign="top" width="50%">
<P><B> Element</B></P>
</TD>
<TD vAlign="top" width="50%">
<P><B> Value</B>
</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
@ -194,11 +196,11 @@ bool regex_search(BidirectionalIterator first, BidirectionalIterator last,
<TD vAlign="top" width="50%">
<P>m[0].matched</P>
</TD>
<TD vAlign="top" width="50%"><CODE>
<P>
true</CODE> if a full match was found, and <CODE>false</CODE> if it was a
partial match (found as a result of the <CODE>match_partial</CODE> flag being
set).</P></TD>
<TD vAlign="top" width="50%">
<P><CODE> true</CODE> if a full match was found, and <CODE>false</CODE> if it was
a partial match (found as a result of the <CODE>match_partial</CODE> flag being
set).</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
@ -227,54 +229,47 @@ bool regex_search(BidirectionalIterator first, BidirectionalIterator last,
<TD vAlign="top" width="50%">
<P>For all integers n &lt; m.size(), true if sub-expression <I>n</I> participated
in the match, false otherwise.</P>
<P></P>
</TD>
</TR>
</TD></TR></TABLE>
</CENTER>
</DIV>
<PRE>template &lt;class charT, class Allocator, class traits, class Allocator2&gt;
bool regex_search(const charT* str, <a href=match_results.html>match_results</a>&lt;const charT*, Allocator&gt;&amp; m,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator2&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>regex_search(str, str +
char_traits&lt;charT&gt;::length(str), m, e, flags)</CODE>.</P><PRE>template &lt;class ST, class SA, class Allocator, class charT,
bool regex_search(const charT* str, <a href="match_results.html">match_results</a>&lt;const charT*, Allocator&gt;&amp; m,
const <a href="basic_regex.html">basic_regex</a>&lt;charT, traits, Allocator2&gt;&amp; e,
<a href="match_flag_type.html">match_flag_type</a> flags = match_default);</PRE>
<P><B> Effects:</B> Returns the result of <CODE>regex_search(str, str +
char_traits&lt;charT&gt;::length(str), m, e, flags)</CODE>.</P>
<PRE>template &lt;class ST, class SA, class Allocator, class charT,
class traits, class Allocator2&gt;
bool regex_search(const basic_string&lt;charT, ST, SA&gt;&amp; s,
<a href=match_results.html>match_results</a>&lt;typename basic_string&lt;charT, ST, SA&gt;::const_iterator, Allocator&gt;&amp; m,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator2&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>regex_search(s.begin(), s.end(), m, e,
flags)</CODE>.</P><PRE>template &lt;class iterator, class Allocator, class charT,
<a href="match_results.html">match_results</a>&lt;typename basic_string&lt;charT, ST, SA&gt;::const_iterator, Allocator&gt;&amp; m,
const <a href="basic_regex.html">basic_regex</a>&lt;charT, traits, Allocator2&gt;&amp; e,
<a href="match_flag_type.html">match_flag_type</a> flags = match_default);</PRE>
<P><B> Effects:</B> Returns the result of <CODE>regex_search(s.begin(), s.end(), m,
e, flags)</CODE>.</P>
<PRE>template &lt;class iterator, class Allocator, class charT,
class traits&gt;
bool regex_search(iterator first, iterator last,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Behaves "as if" by constructing an instance of <CODE><a href="match_results.html">
match_results</a>&lt;</CODE>BidirectionalIterator<CODE>&gt; what</CODE>,
and then returning the result of <CODE>regex_search(first, last, what, e, flags)</CODE>.</P><PRE>template &lt;class charT, class Allocator, class traits&gt;
const <a href="basic_regex.html">basic_regex</a>&lt;charT, traits, Allocator&gt;&amp; e,
<a href="match_flag_type.html">match_flag_type</a> flags = match_default);</PRE>
<P><B> Effects:</B> Behaves "as if" by constructing an instance of <CODE><a href="match_results.html">
match_results</a>&lt;</CODE>BidirectionalIterator<CODE>&gt; what</CODE>,
and then returning the result of <CODE>regex_search(first, last, what, e, flags)</CODE>.</P>
<PRE>template &lt;class charT, class Allocator, class traits&gt;
bool regex_search(const charT* str
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>regex_search(str, str +
char_traits&lt;charT&gt;::length(str), e, flags)</CODE>.</P><PRE>template &lt;class ST, class SA, class Allocator, class charT,
const <a href="basic_regex.html">basic_regex</a>&lt;charT, traits, Allocator&gt;&amp; e,
<a href="match_flag_type.html">match_flag_type</a> flags = match_default);</PRE>
<P><B> Effects:</B> Returns the result of <CODE>regex_search(str, str +
char_traits&lt;charT&gt;::length(str), e, flags)</CODE>.</P>
<PRE>template &lt;class ST, class SA, class Allocator, class charT,
class traits&gt;
bool regex_search(const basic_string&lt;charT, ST, SA&gt;&amp; s,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>regex_search(s.begin(), s.end(), e,
flags)</CODE>.
<H3><A name="examples"></A>Examples</H3>
const <a href="basic_regex.html">basic_regex</a>&lt;charT, traits, Allocator&gt;&amp; e,
<a href="match_flag_type.html">match_flag_type</a> flags = match_default);</PRE>
<P><B> Effects:</B> Returns the result of <CODE>regex_search(s.begin(), s.end(), e,
flags)</CODE>.
<H3><A name="examples"></A>Examples</H3>
<P>The following <A href="../example/snippets/regex_search_example.cpp">example</A>,
takes the contents of a file in the form of a string, and searches for all the
C++ class declarations in the file. The code will work regardless of the way
@ -298,7 +293,7 @@ void</B> IndexClasses(map_type&amp; m, <B>const</B> std::string&amp; file)
&nbsp;&nbsp; std::string::const_iterator start, end;
&nbsp;&nbsp; start = file.begin();
&nbsp;&nbsp; end = file.end();&nbsp;
&nbsp;&nbsp; &nbsp;&nbsp; boost::<a href=match_results.html>match_results</a>&lt;std::string::const_iterator&gt; what;
&nbsp;&nbsp; &nbsp;&nbsp; boost::<a href="match_results.html">match_results</a>&lt;std::string::const_iterator&gt; what;
&nbsp;&nbsp; <B>unsigned</B> <B>int</B> flags = boost::match_default;
&nbsp;&nbsp; <B>while</B>(regex_search(start, end, what, expression, flags))&nbsp;
&nbsp;&nbsp; {
@ -315,13 +310,14 @@ void</B> IndexClasses(map_type&amp; m, <B>const</B> std::string&amp; file)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; flags |= boost::match_not_bob;&nbsp;
&nbsp;&nbsp; }
}
<HR></PRE>
</PRE>
<HR>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that

View File

@ -24,7 +24,7 @@
</P>
<HR>
<p></p>
<P>The algorithm regex_split has been deprecated in favour of the iterator <A href="regex_token_iterator.html">
<P>The algorithm regex_split has been deprecated in favor of the iterator <A href="regex_token_iterator.html">
regex_token_iterator</A> which has a more flexible and powerful interface,
as well as following the more usual standard library "pull" rather than "push"
semantics.</P>
@ -51,30 +51,37 @@ std::size_t regex_split(OutputIterator out,&nbsp;
<B>template</B> &lt;<B>class</B> OutputIterator, <B>class</B> charT, <B>class</B> Traits1, <B>class</B> Alloc1&gt;
std::size_t regex_split(OutputIterator out,
std::basic_string&lt;charT, Traits1, Alloc1&gt;&amp; s);</PRE>
<P>Each version takes an output-iterator for output, and a string for input. If
the expression contains no marked sub-expressions, then the algorithm writes
one string onto the output-iterator for each section of input that does not
match the expression. If the expression does contain marked sub-expressions,
then each time a match is found, one string for each marked sub-expression will
be written to the output-iterator. No more than <I>max_split </I>strings will
be written to the output-iterator. Before returning, all the input processed
will be deleted from the string <I>s</I> (if <I>max_split </I>is not reached
then all of <I>s</I> will be deleted). Returns the number of strings written to
the output-iterator. If the parameter <I>max_split</I> is not specified then it
defaults to UINT_MAX. If no expression is specified, then it defaults to "\s+",
and splitting occurs on whitespace.
<P><STRONG>Effects: </STRONG>Each version of the algorithm takes an
output-iterator for output, and a string for input. If the expression contains
no marked sub-expressions, then the algorithm writes one string onto the
output-iterator for each section of input that does not match the expression.
If the expression does contain marked sub-expressions, then each time a match
is found, one string for each marked sub-expression will be written to the
output-iterator. No more than <I>max_split </I>strings will be written to the
output-iterator. Before returning, all the input processed will be deleted from
the string <I>s</I> (if <I>max_split </I>is not reached then all of <I>s</I> will
be deleted). Returns the number of strings written to the output-iterator. If
the parameter <I>max_split</I> is not specified then it defaults to UINT_MAX.
If no expression is specified, then it defaults to "\s+", and splitting occurs
on whitespace.
</P>
<P><A href="../example/snippets/regex_split_example_1.cpp">Example</A>: the following
function will split the input string into a series of tokens, and remove each
token from the string <I>s</I>:
<P><STRONG>Throws:</STRONG> <CODE>std::runtime_error</CODE> if the complexity of
matching the expression against an N character string begins to exceed O(N<SUP>2</SUP>),
or if the program runs out of stack space while matching the expression (if
Boost.regex is <A href="configuration.html">configured</A> in recursive mode),
or if the matcher exhausts it's permitted memory allocation (if Boost.regex is <A href="configuration.html">
configured</A> in non-recursive mode).</P>
<P><A href="../example/snippets/regex_split_example_1.cpp">Example</A>: the
following function will split the input string into a series of tokens, and
remove each token from the string <I>s</I>:
</P>
<PRE><B>unsigned</B> tokenise(std::list&lt;std::string&gt;&amp; l, std::string&amp; s)
{
<B>&nbsp;&nbsp; return</B> boost::regex_split(std::back_inserter(l), s);
}</PRE>
<P><A href="../example/snippets/regex_split_example_2.cpp">Example</A>: the following
short program will extract all of the URL's from a html file, and print them
out to <I>cout</I>:
<P><A href="../example/snippets/regex_split_example_2.cpp">Example</A>: the
following short program will extract all of the URL's from a html file, and
print them out to <I>cout</I>:
</P>
<PRE><FONT color=#008000>#include &lt;list&gt;
#include &lt;fstream&gt;
@ -124,15 +131,13 @@ boost::regex e(<FONT color=#000080>"&lt;\\s*A\\s+[^&gt;]*href\\s*=\\s*\"([^\"]*)
}
<B>return</B> 0;
}</PRE>
<P>
<HR>
<P></P>
<HR>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that

View File

@ -72,40 +72,44 @@ public:
</PRE>
<H3><A name="description"></A>Description</H3>
<PRE>regex_token_iterator();</PRE>
<B>
<P>
Effects:</B> constructs an end of sequence iterator.</P><PRE>regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type&amp; re,
<P><B> Effects:</B> constructs an end of sequence iterator.</P>
<PRE>regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type&amp; re,
int submatch = 0, match_flag_type m = match_default);</PRE>
<B>
<P>
Preconditions: </B><CODE>!re.empty()</CODE>.</P><B>
<P>
Effects:</B> constructs a regex_token_iterator that will enumerate one
string for each regular expression match of the expression <EM>re</EM> found
within the sequence <EM>[a,b)</EM>, using match flags <EM>m</EM>.&nbsp; The
string enumerated is the&nbsp;sub-expression <EM>submatch </EM>for each match
found; if <EM>submatch </EM>is -1, then enumerates all the text sequences that
did not match the expression <EM>re </EM>(that is to performs field
splitting).</P><PRE>regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type&amp; re,
<P><B> Preconditions: </B><CODE>!re.empty()</CODE>.</P>
<P><B> Effects:</B> constructs a regex_token_iterator that will enumerate one
string for each regular expression match of the expression <EM>re</EM> found
within the sequence <EM>[a,b)</EM>, using match flags <EM>m</EM>.&nbsp; The
string enumerated is the&nbsp;sub-expression <EM>submatch </EM>for each match
found; if <EM>submatch </EM>is -1, then enumerates all the text sequences that
did not match the expression <EM>re </EM>(that is to performs field splitting).</P>
<P><STRONG>Throws:</STRONG> <CODE>std::runtime_error</CODE> if the complexity of
matching the expression against an N character string begins to exceed O(N<SUP>2</SUP>),
or if the program runs out of stack space while matching the expression (if
Boost.regex is <A href="configuration.html">configured</A> in recursive mode),
or if the matcher exhausts it's permitted memory allocation (if Boost.regex is <A href="configuration.html">
configured</A> in non-recursive mode).</P>
<PRE>regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type&amp; re,
const std::vector&lt;int&gt;&amp; submatches, match_flag_type m = match_default);</PRE>
<B>
<P>
Preconditions:</B> <CODE>submatches.size() &amp;&amp; !re.empty()</CODE>.</P><B>
<P>
Effects:</B> constructs a regex_token_iterator that will enumerate <EM>submatches.size()</EM>
strings for each regular expression match of the expression <EM>re</EM> found
within the sequence <EM>[a,b)</EM>, using match flags <EM>m</EM>.&nbsp; For
each match found one string will be enumerated&nbsp;for each sub-expression
index&nbsp;contained within <EM>submatches </EM>vector; if <EM>submatches[0] </EM>
is -1, then the first string enumerated for each match will be all of the text
from end of the last match to the start of the current match, in addition there
will be one extra string enumerated when no more matches can be found: from the
end of the last match found, to the end of the underlying sequence.</P><PRE>template &lt;std::size_t N&gt;
<P><B> Preconditions:</B> <CODE>submatches.size() &amp;&amp; !re.empty()</CODE>.</P>
<P><B> Effects:</B> constructs a regex_token_iterator that will enumerate <EM>submatches.size()</EM>
strings for each regular expression match of the expression <EM>re</EM> found
within the sequence <EM>[a,b)</EM>, using match flags <EM>m</EM>.&nbsp; For
each match found one string will be enumerated&nbsp;for each sub-expression
index&nbsp;contained within <EM>submatches </EM>vector; if <EM>submatches[0] </EM>
is -1, then the first string enumerated for each match will be all of the text
from end of the last match to the start of the current match, in addition there
will be one extra string enumerated when no more matches can be found: from the
end of the last match found, to the end of the underlying sequence.</P>
<P><STRONG>Throws:</STRONG> <CODE>std::runtime_error</CODE> if the complexity of
matching the expression against an N character string begins to exceed O(N<SUP>2</SUP>),
or if the program runs out of stack space while matching the expression (if
Boost.regex is <A href="configuration.html">configured</A> in recursive mode),
or if the matcher exhausts it's permitted memory allocation (if Boost.regex is <A href="configuration.html">
configured</A> in non-recursive mode).</P>
<PRE>template &lt;std::size_t N&gt;
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type&amp; re,
const int (&amp;submatches)[R], match_flag_type m = match_default);</PRE>
<B>
<P>
Preconditions: </B><CODE>!re.empty()</CODE>.</P>
<P><B> Preconditions: </B><CODE>!re.empty()</CODE>.</P>
<P><STRONG>Effects:</STRONG></B> constructs a regex_token_iterator that will
enumerate&nbsp;<EM>R</EM> strings for each regular expression match of the
expression <EM>re</EM> found within the sequence <EM>[a,b)</EM>, using match
@ -116,41 +120,46 @@ regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const reg
of the current match, in addition there will be one extra string enumerated
when no more matches can be found: from the end of the last match found, to the
end of the underlying sequence.</P>
<P><STRONG>Throws:</STRONG> <CODE>std::runtime_error</CODE> if the complexity of
matching the expression against an N character string begins to exceed O(N<SUP>2</SUP>),
or if the program runs out of stack space while matching the expression (if
Boost.regex is <A href="configuration.html">configured</A> in recursive mode),
or if the matcher exhausts it's permitted memory allocation (if Boost.regex is <A href="configuration.html">
configured</A> in non-recursive mode).</P>
<PRE>regex_token_iterator(const regex_token_iterator&amp; that);</PRE>
<P><B> Effects: </B>constructs a copy of <CODE>that</CODE>.</P>
<P><B> Postconditions:</B> <CODE>*this == that</CODE>.</P>
<PRE>regex_token_iterator&amp; operator=(const regex_token_iterator&amp; that);</PRE>
<P><B> Effects: </B>sets <CODE>*this</CODE> to be equal to&nbsp;<CODE>that</CODE>.</P>
<P><B> Postconditions:</B> <CODE>*this == that</CODE>.</P>
<PRE>bool operator==(const regex_token_iterator&amp;);</PRE>
<P>
<B>Effects: </B>returns true if *this is the same position as that.</P>
<PRE>bool operator!=(const regex_token_iterator&amp;);</PRE>
<P>
<B>Effects: </B>returns <CODE>!(*this == that)</CODE>.</P>
<PRE>const value_type&amp; operator*();</PRE>
<P>
<B>Effects: </B>returns the current string being enumerated.</P>
<PRE>const value_type* operator-&gt;();</PRE>
<P>
<B>Effects: </B>returns <CODE>&amp;(*this)</CODE>.</P>
<PRE>regex_token_iterator&amp; operator++();</PRE>
<P>
<B>Effects: </B>Moves on to the next string to be enumerated.</P>
<P><STRONG>Throws:</STRONG> <CODE>std::runtime_error</CODE> if the complexity of
matching the expression against an N character string begins to exceed O(N<SUP>2</SUP>),
or if the program runs out of stack space while matching the expression (if
Boost.regex is <A href="configuration.html">configured</A> in recursive mode),
or if the matcher exhausts it's permitted memory allocation (if Boost.regex is <A href="configuration.html">
configured</A> in non-recursive mode).</P>
<B>
<P>
Effects: </B>constructs a copy of <CODE>that</CODE>.</P><B>
<P>
Postconditions:</B> <CODE>*this == that</CODE>.</P><PRE>regex_token_iterator&amp; operator=(const regex_token_iterator&amp; that);</PRE>
<B>
<P>
Effects: </B>sets <CODE>*this</CODE> to be equal to&nbsp;<CODE>that</CODE>.</P><B>
<P>
Postconditions:</B> <CODE>*this == that</CODE>.</P><PRE>bool operator==(const regex_token_iterator&amp;);</PRE>
<B>
<P>
Effects: </B>returns true if *this is the same position as that.</P><PRE>bool operator!=(const regex_token_iterator&amp;);</PRE>
<B>
<P>
Effects: </B>returns <CODE>!(*this == that)</CODE>.</P><PRE>const value_type&amp; operator*();</PRE>
<B>
<P>
Effects: </B>returns the current string being enumerated.</P><PRE>const value_type* operator-&gt;();</PRE>
<B>
<P>
Effects: </B>returns <CODE>&amp;(*this)</CODE>.</P><PRE>regex_token_iterator&amp; operator++();</PRE>
<B>
<P>
Effects: </B>Moves on to the next string to be enumerated.</P><B>
<P>
Returns:</B><CODE> *this</CODE>.</P><PRE>regex_token_iterator&amp; operator++(int);</PRE>
<B>
<P>
Effects:</B> constructs a copy <CODE>result</CODE> of <CODE>*this</CODE>,
then calls <CODE>++(*this)</CODE>.</P><B>
<P>
Returns:</B> <CODE>result</CODE>.<A name="examples"></A>
<H3>Examples</H3>
<P><B> Effects:</B> constructs a copy <CODE>result</CODE> of <CODE>*this</CODE>,
then calls <CODE>++(*this)</CODE>.</P>
<P><B> Returns:</B> <CODE>result</CODE>.<A name="examples"></A>
<H3>Examples</H3>
<P>The following <A href="../example/snippets/regex_token_iterator_example_1.cpp">example</A>
takes a string and splits it into a series of tokens:</P>
<pre>
@ -260,12 +269,10 @@ boost::regex e(<FONT color=#0000ff>"&lt;\\s*A\\s+[^&gt;]*href\\s*=\\s*\"([^\"]*)
<B>return</B> <FONT color=#0000a0>0</FONT>;
}
</pre>
<P>
<HR>
<P></P>
<HR>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>

View File

@ -33,7 +33,7 @@
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
@ -45,3 +45,4 @@
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -23,10 +23,9 @@
</TABLE>
</P>
<HR>
<p></p>
<H3>C++</H3>
<P>Boost.regex is intended to conform to the <A href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1429.htm">
regular expression standardisation proposal</A>, which will appear in a
regular expression standardization proposal</A>, which will appear in a
future C++ standard technical report (and hopefully in a future version of the
standard).&nbsp; Currently there are some differences in how the regular
expression traits classes are defined, these will be fixed in a future release.</P>
@ -36,10 +35,10 @@
<P>Negated class escapes (\S, \D and \W) are not permitted inside character class
definitions ( [...] ).</P>
<P>The escape sequence \u matches any upper case character (the same as
[[:upper:]])&nbsp;rather than a unicode escape sequence; use \x{DDDD} for
unicode escape sequences.</P>
[[:upper:]])&nbsp;rather than a Unicode escape sequence; use \x{DDDD} for
Unicode escape sequences.</P>
<H3>Perl</H3>
<P>Almost all perl features are supported, except for:</P>
<P>Almost all Perl features are supported, except for:</P>
<P>\N{name}&nbsp; Use [[:name:]] instead.</P>
<P>\pP and \PP</P>
<P>(?imsx-imsx)</P>
@ -48,25 +47,23 @@
<P>(?{code})</P>
<P>(??{code})</P>
<P>(?(condition)yes-pattern) and (?(condition)yes-pattern|no-pattern)</P>
<P>These embarressments / limitations will be removed in due course, mainly
<P>These embarrassments / limitations will be removed in due course, mainly
dependent upon user demand.</P>
<H3>POSIX</H3>
<P>All the POSIX basic and extended regular expression features are supported,
except that:</P>
<P>No character collating names are recognised except those specified in the POSIX
<P>No character collating names are recognized except those specified in the POSIX
standard for the C locale, unless they are explicitly registered with the
traits class.</P>
<P>Character equivalence classes ( [[=a=]] etc) are probably buggy except on
Win32.&nbsp; Implimenting this feature requires knowledge of the format of the
Win32.&nbsp; Implementing this feature requires knowledge of the format of the
string sort keys produced by the system; if you need this, and the default
implementation doesn't work on your platfrom, then you will need to supply a
implementation doesn't work on your platform, then you will need to supply a
custom traits class.</P>
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
@ -78,3 +75,5 @@
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -23,7 +23,6 @@
</TABLE>
</P>
<HR>
<p></p>
<H3>Synopsis</H3>
<P>#include &lt;<A href="../../boost/regex.hpp">boost/regex.hpp</A>&gt;
</P>
@ -94,42 +93,42 @@ bool operator &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool operator == (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; lhs,
bool operator == (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 operator != (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; lhs,
bool operator != (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 operator &lt; (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; lhs,
bool operator &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 operator &gt; (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; lhs,
bool operator &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 operator &gt;= (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; lhs,
bool operator &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 operator &lt;= (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; lhs,
bool operator &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 operator == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; rhs);
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 operator != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; rhs);
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 operator &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; rhs);
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 operator &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; rhs);
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 operator &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; rhs);
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 operator &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; rhs);
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator == (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
@ -229,191 +228,189 @@ basic_ostream&lt;charT, traits&gt;&amp;
<PRE>bool matched</PRE>
<P>A Boolean value denoting whether this sub-expression participated in the match.</P>
<PRE>static difference_type length();</PRE>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>(matched ? 0 : distance(first, second))</CODE>.</P><PRE>operator basic_string&lt;value_type&gt;()const;</PRE>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>(matched ? basic_string&lt;value_type&gt;(first,
second) : basic_string&lt;value_type&gt;()).</P></CODE><PRE>basic_string&lt;value_type&gt; str()const;</PRE>
<B>
<P>
<P><B>
Effects: </B>returns <CODE>(matched ? basic_string&lt;value_type&gt;(first,
second) : basic_string&lt;value_type&gt;())</CODE>.</P><PRE>int compare(const sub_match&amp; s)const;</PRE>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>str().compare(s.str())</CODE>.</P><PRE>int compare(const basic_string&lt;value_type&gt;&amp; s)const;</PRE>
<B>
<P>
<P><B>
Effects: </B>returns <CODE>str().compare(s)</CODE>.</P><PRE>int compare(const value_type* s)const;</PRE>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>str().compare(s)</CODE>.</P>
<H4>
sub_match non-member operators</H4>
<PRE>template &lt;class BidirectionalIterator&gt;
bool operator == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);</PRE>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs.compare(rhs) == 0</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);</PRE>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs.compare(rhs) != 0</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs.compare(rhs) &lt; 0</CODE>.</P><PRE>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>
<B>
<P>
<P><B>
Effects: </B>returns <CODE>lhs.compare(rhs) &lt;= 0</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs.compare(rhs) &gt;= 0</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs.compare(rhs) &gt; 0</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs == rhs.str()</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs != rhs.str()</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs &lt; rhs.str()</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs &gt; rhs.str()</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs &gt;= rhs.str()</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs &lt;= rhs.str()</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs.str() == rhs</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs.str() != rhs</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs.str() &lt; rhs</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs.str() &gt; rhs</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs.str() &gt;= rhs</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs.str() &lt;= rhs</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs == rhs.str()</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs != rhs.str()</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs &lt; rhs.str()</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs &gt; rhs.str()</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs &gt;= rhs.str()</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs &lt;= rhs.str()</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs.str() == rhs</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs.str() != rhs</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs.str() &lt; rhs</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs.str() &gt; rhs</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs.str() &gt;= rhs</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs.str() &lt;= rhs</CODE>.</P><PRE>template &lt;class charT, class traits, class BidirectionalIterator&gt;
basic_ostream&lt;charT, traits&gt;&amp;
operator &lt;&lt; (basic_ostream&lt;charT, traits&gt;&amp; os
const sub_match&lt;BidirectionalIterator&gt;&amp; m);</PRE>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>(os &lt;&lt; m.str())</CODE>.
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
@ -425,3 +422,5 @@ basic_ostream&lt;charT, traits&gt;&amp;
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -23,7 +23,6 @@
</TABLE>
</P>
<HR>
<p></p>
<P>This section covers the regular expression syntax used by this library, this is
a programmers guide, the actual syntax presented to your program's users will
depend upon the flags used during expression compilation.
@ -34,7 +33,7 @@
"}", "[", "]", "^", "$" and "\". These characters are literals when preceded by
a "\". A literal is a character that matches itself, or matches the result of
traits_type::translate(), where traits_type is the traits template parameter to
class reg_expression.</P>
class basic_regex.</P>
<H3>Wildcard
</H3>
<P>The dot character "." matches any single character except : when <I>match_not_dot_null</I>
@ -123,14 +122,14 @@
expression "abc".</P>
<H3>Independent sub-expressions</H3>
<P>"(?&gt;expression)" matches "expression" as an independent atom (the algorithm
will not backtrack into it if a failure occures later in the expression).</P>
will not backtrack into it if a failure occurs later in the expression).</P>
<H3>Alternatives
</H3>
<P>Alternatives occur when the expression can match either one sub-expression or
another, each alternative is separated by a "|", or a "\|" if the flag
regex_constants::bk_vbar is set, or by a newline character if the flag
regex_constants::newline_alt is set. Each alternative is the largest possible
previous sub-expression; this is the opposite behaviour from repetition
previous sub-expression; this is the opposite behavior from repetition
operators.
</P>
<P>Examples:
@ -167,7 +166,7 @@
when the default "C" locale is in effect. For example if the library is
compiled with the Win32 localization model, then [a-z] will match the ASCII
characters a-z, and also 'A', 'B' etc, but not 'Z' which collates just after
'z'. This locale specific behaviour is disabled by default (in perl mode), and
'z'. This locale specific behavior is disabled by default (in perl mode), and
forces ranges to collate according to ASCII character code.
</P>
<P>Character classes are denoted using the syntax "[:classname:]" within a set
@ -263,7 +262,7 @@
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">unicode</TD>
<TD vAlign="top" width="50%">Unicode</TD>
<TD vAlign="top" width="50%">Any character whose code is greater than 255, this
applies to the wide character traits classes only.</TD>
<TD>&nbsp;</TD>
@ -373,7 +372,7 @@
</P>
<H3>Buffer operators
</H3>
<P>The following operators are provide for compatibility with the GNU regular
<P>The following operators are provided for compatibility with the GNU regular
expression library, and Perl regular expressions:
</P>
<P>"\`" matches the start of a buffer.
@ -521,7 +520,7 @@
<TD vAlign="top" width="33%">0xXX
</TD>
<TD vAlign="top" width="33%">A hexadecimal character code, where XX is one or more
hexadecimal digits, optionally a unicode character.
hexadecimal digits, optionally a Unicode character.
</TD>
<TD>&nbsp;</TD>
</TR>
@ -667,9 +666,9 @@
<H3>What gets matched?
</H3>
<P>
When the expression is compiled as a perl-compatible regex then the matching
When the expression is compiled as a Perl-compatible regex then the matching
algorithms will perform a depth first search on the state machine and report
the first match found.
the first match found.</P>
<P>
When the expression is compiled as a POSIX-compatible regex then the matching
algorithms will match the first possible matching string, if more than one
@ -683,15 +682,11 @@
chosen is the one with the longest first sub-expression, if that is the same
for two or more matches, then the second sub-expression will be examined and so
on.
<P></P>
The following table examples illustrate the main differences between perl and
</P><P>
The following table examples illustrate the main differences between Perl and
POSIX regular expression matching rules:
<P></P>
</P>
<P>
<DIV align="center">
<P></P>
<P align="center">
<CENTER>
<TABLE id="Table5" cellSpacing="1" cellPadding="7" width="624" border="1">
<TBODY>
<TR>
@ -709,29 +704,27 @@
</TD>
</TR>
<TR>
<TD vAlign="top" width="25%"><CODE>
<P>
a|ab</CODE>
</P>
<TD vAlign="top" width="25%">
<P><CODE>a|ab</CODE></P>
</TD>
<TD vAlign="top" width="25%"><CODE>
<P>
<TD vAlign="top" width="25%">
<P><CODE>
xaby</CODE>
</P>
</TD>
<TD vAlign="top" width="25%"><CODE>
<P>
<TD vAlign="top" width="25%">
<P><CODE>
"ab"</CODE></P></TD>
<TD vAlign="top" width="25%"><CODE>
<P>
<TD vAlign="top" width="25%">
<P><CODE>
"a"</CODE></P></TD>
</TR>
<TR>
<TD vAlign="top" width="25%"><CODE>
<P>
<TD vAlign="top" width="25%">
<P><CODE>
.*([[:alnum:]]+).*</CODE></P></TD>
<TD vAlign="top" width="25%"><CODE>
<P>
<TD vAlign="top" width="25%">
<P><CODE>
" abc def xyz "</CODE></P></TD>
<TD vAlign="top" width="25%">
<P>$0 = " abc def xyz "<BR>
@ -743,33 +736,28 @@
</TD>
</TR>
<TR>
<TD vAlign="top" width="25%"><CODE>
<P>
<TD vAlign="top" width="25%">
<P><CODE>
.*(a|xayy)</CODE></P></TD>
<TD vAlign="top" width="25%"><CODE>
<P>
<TD vAlign="top" width="25%">
<P><CODE>
zzxayyzz</CODE></P></TD>
<TD vAlign="top" width="25%"><CODE>
<P>
<TD vAlign="top" width="25%">
<P><CODE>
"zzxayy"</CODE></P></TD>
<TD vAlign="top" width="25%"><CODE>
<P>"zzxa"</P>
<P></P>
</CODE>
<TD vAlign="top" width="25%">
<P><CODE>"zzxa"</CODE></P>
</TD>
</TR>
</TBODY></CODE></TD></TR></TABLE></CENTER>
<P></P>
</DIV>
<P>These differences between perl matching rules, and POSIX matching rules, mean
</TBODY></CODE></TD></TR></TABLE>
<P>These differences between Perl matching rules, and POSIX matching rules, mean
that these two regular expression syntaxes differ not only in the features
offered, but also in the form that the state machine takes and/or the
algorithms used to traverse the state machine.
algorithms used to traverse the state machine.</p>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
@ -781,3 +769,5 @@
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -23,7 +23,6 @@
</TABLE>
</P>
<HR>
<p></p>
<H3>Synopsis</H3>
<P>Type syntax_option type is an implementation defined bitmask type that controls
how a regular expression string is to be interpreted.&nbsp; For convenience
@ -83,7 +82,7 @@ static const syntax_option_type perl;<BR>// these are boost.regex specific:<BR>s
normal semantics: that is the same as that given in the ECMA-262, ECMAScript
Language Specification, Chapter 15 part 10, RegExp (Regular Expression) Objects
(FWD.1).</P>
<P>boost.regex also recognises most perl-compatible extensions in this mode.</P>
<P>boost.regex also recognizes most perl-compatible extensions in this mode.</P>
</TD>
</TR>
<TR>
@ -229,7 +228,6 @@ static const syntax_option_type perl;<BR>// these are boost.regex specific:<BR>s
</TR>
</TABLE>
</P>
<P>
<P>The following constants are specific to this particular regular expression
implementation and do not appear in the <A href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1429.htm">
regular expression standardization proposal</A>:</P>
@ -279,7 +277,7 @@ static const syntax_option_type perl;<BR>// these are boost.regex specific:<BR>s
<TD vAlign="top" width="45%">regbase:: bk_parens</TD>
<TD vAlign="top" width="45%">When this bit is set then "\(" and "\)" are used to
group sub-expressions and "(" and ")" are ordinary characters, this is the
opposite of default behaviour.</TD>
opposite of default behavior.</TD>
</TR>
<TR>
<TD vAlign="top" width="45%">regbase:: bk_refs</TD>
@ -290,13 +288,13 @@ static const syntax_option_type perl;<BR>// these are boost.regex specific:<BR>s
<TD vAlign="top" width="45%">regbase:: bk_vbar</TD>
<TD vAlign="top" width="45%">When this bit is set then "\|" represents the
alternation operator and "|" is an ordinary character. This is the opposite of
default behaviour.</TD>
default behavior.</TD>
</TR>
<TR>
<TD vAlign="top" width="45%">regbase:: use_except</TD>
<TD vAlign="top" width="45%">When this bit is set then a <A href="#bad_expression">bad_expression</A>
exception will be thrown on error.&nbsp; Use of this flag is deprecated -
reg_expression will always throw on error.</TD>
basic_regex will always throw on error.</TD>
</TR>
<TR>
<TD vAlign="top" width="45%">regbase:: failbit</TD>
@ -316,12 +314,10 @@ static const syntax_option_type perl;<BR>// these are boost.regex specific:<BR>s
</TR>
</TABLE>
</P>
<P>
<HR>
</P>
<P>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></P>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
@ -332,3 +328,5 @@ static const syntax_option_type perl;<BR>// these are boost.regex specific:<BR>s
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -23,39 +23,40 @@
</TABLE>
</P>
<HR>
<p></p>
<P>Class basic_regex&lt;&gt; and its typedefs regex and wregex are thread safe, in
that compiled regular expressions can safely be shared between threads. The
matching algorithms regex_match, regex_search, regex_grep, regex_format and
regex_merge are all re-entrant and thread safe. Class match_results is now
thread safe, in that the results of a match can be safely copied from one
thread to another (for example one thread may find matches and push
<P>Class <A href="basic_regex.html">basic_regex</A>&lt;&gt; and its typedefs regex
and wregex are thread safe, in that compiled regular expressions can safely be
shared between threads. The matching algorithms <A href="regex_match.html">regex_match</A>,
<A href="regex_search.html">regex_search</A>, <A href="regex_grep.html">regex_grep</A>,
<A href="regex_format.html">regex_format</A> and <A href="regex_merge.html">regex_merge</A>
are all re-entrant and thread safe. Class <A href="match_results.html">match_results</A>
is now thread safe, in that the results of a match can be safely copied from
one thread to another (for example one thread may find matches and push
match_results instances onto a queue, while another thread pops them off the
other end), otherwise use a separate instance of match_results per thread.
other end), otherwise use a separate instance of <A href="match_results.html">match_results</A>
per thread.
</P>
<P>The POSIX API functions are all re-entrant and thread safe, regular expressions
compiled with <I>regcomp</I> can also be shared between threads.
<P>The <A href="posix_api.html">POSIX API functions</A> are all re-entrant and
thread safe, regular expressions compiled with <I>regcomp</I> can also be
shared between threads.
</P>
<P>The class RegEx is only thread safe if each thread gets its own RegEx instance
(apartment threading) - this is a consequence of RegEx handling both compiling
and matching regular expressions.
<P>The class<A href="regex.html"> RegEx</A> is only thread safe if each thread
gets its own RegEx instance (apartment threading) - this is a consequence of
RegEx handling both compiling and matching regular expressions.
</P>
<P>Finally note that changing the global locale invalidates all compiled regular
expressions, therefore calling <I>set_locale</I> from one thread while another
uses regular expressions <I>will</I> produce unpredictable results.
</P>
<P>
There is also a requirement that there is only one thread executing prior to
the start of main().
<P>
<HR>
<P></P>
There is also a requirement that there is only one thread executing prior to
the start of main().</P>
<HR>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
@ -64,3 +65,4 @@
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -65,7 +65,7 @@ bad_expression(const string&amp; what_arg);
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
<p><i><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
@ -79,3 +79,4 @@ bad_expression(const string&amp; what_arg);
for any purpose. It is provided "as is" without express or implied warranty.</i></p>
</body>
</html>

File diff suppressed because it is too large Load Diff

View File

@ -4,18 +4,16 @@
<title>Boost.Regex: Configuration and setup</title>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content=
"text/html; charset=iso-8859-1" >
"text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<p></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>
"C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<td width="353">
<h1 align="center">Boost.Regex</h1>
@ -24,7 +22,7 @@ border="0">
</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>
"Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</tr>
</table>
@ -37,13 +35,13 @@ border="0">
<h2>Contents</h2>
<dl class="index">
<dt><a href="#compiler">Compiler setup</a>
<dt><a href="#compiler">Compiler setup</a></dt>
<dt><a href="#locale">Locale and traits class selection</a>
<dt><a href="#locale">Locale and traits class selection</a></dt>
<dt><a href="#linkage">Linkage Options</a>
<dt><a href="#linkage">Linkage Options</a></dt>
<dt><a href="#algorithm">Algorithm Selection</a>
<dt><a href="#algorithm">Algorithm Selection</a></dt>
<dt><a href="#tuning">Algorithm Tuning</a></dt>
</dl>
@ -60,8 +58,6 @@ particularly obscure compiler or platform) then <a href="../../config/index.html
<p>The following macros (see <a href="../../../boost/regex/user.hpp">user.hpp</a>) control how
boost.regex interacts with the user's locale:</p>
<p></p>
<table id="Table2" cellspacing="1" cellpadding="1" width="100%"
border="1">
<tr>
@ -93,16 +89,14 @@ BOOST_REGEX_USE_CPP_LOCALE is set).</td>
<h3><a name="linkage"></a>Linkage Options</h3>
<p></p>
<table id="Table3" cellspacing="1" cellpadding="1" width="100%"
border="1">
<tr>
<td>BOOST_REGEX_DYN_LINK</td>
<td>For Microsoft and Borland C++ builds, this tells
boost.regex that it should link to the dll build of the boost.regex.&nbsp; By default
boost.regex will link to its static library build, even if the dynamic C runtime library
is in use.</td>
<td>For Microsoft and Borland C++ builds, this tells boost.regex
that it should link to the dll build of the boost.regex.&nbsp; By
default boost.regex will link to its static library build, even if
the dynamic C runtime library is in use.</td>
</tr>
<tr>
@ -119,8 +113,6 @@ to.</td>
<h3><a name="algorithm"></a>Algorithm Selection</h3>
<p></p>
<table id="Table4" cellspacing="1" cellpadding="1" width="100%"
border="1">
<tr>
@ -157,8 +149,6 @@ expression.&nbsp; This is the default on non-Win32 platforms.</td>
<p>The following option applies only if BOOST_REGEX_RECURSIVE is
set.</p>
<p></p>
<table id="Table6" cellspacing="1" cellpadding="1" width="100%"
border="1">
<tr>
@ -175,8 +165,6 @@ are supported, and can be used to safely trap stack overflow.</td>
<p>The following options apply only if BOOST_REGEX_NON_RECURSIVE is
set.</p>
<p></p>
<table id="Table5" cellspacing="1" cellpadding="1" width="100%"
border="1">
<tr>
@ -220,16 +208,13 @@ order.</td>
<br>
<p></p>
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->11
April 2003
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
<p><i><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John
Maddock</a>&nbsp;1998-
<p><i>&copy; Copyright <a href="mailto:jm@regex.fsnet.co.uk">John
Maddock</a>&nbsp;1998-
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
@ -243,3 +228,5 @@ software for any purpose. It is provided "as is" without express or
implied warranty.</i></p>
</body>
</html>

View File

@ -90,8 +90,7 @@ papers available from their respective web sites.</p>
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->11
April 2003
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
<p><i><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John

View File

@ -81,8 +81,7 @@
<P></P>
<HR>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->11
April 2003
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
<p><i><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John
@ -97,3 +96,4 @@ Maddock</a>&nbsp;1998-
for any purpose. It is provided "as is" without express or implied warranty.</i></p>
</body>
</html>

View File

@ -1,118 +1,162 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: FAQ</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">FAQ</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>
<FONT color="#ff0000"><FONT color="#ff0000">
<P><FONT color="#ff0000">&nbsp;Q. Why can't I use the "convenience" versions of
regex_match / regex_search / regex_grep / regex_format / regex_merge?</FONT>
</P>
</FONT></FONT>
<P>A. These versions may or may not be available depending upon the capabilities
of your compiler, the rules determining the format of these functions are quite
complex - and only the versions visible to a standard compliant compiler are
given in the help. To find out what your compiler supports, run
&lt;boost/regex.hpp&gt; through your C++ pre-processor, and search the output
file for the function that you are interested in.<FONT color="#ff0000"><FONT color="#ff0000">
</P>
<P>Q. I can't get regex++ to work with escape characters, what's going on?</FONT>
</P>
</FONT>
<P>A. If you embed regular expressions in C++ code, then remember that escape
characters are processed twice: once by the C++ compiler, and once by the
regex++ expression compiler, so to pass the regular expression \d+ to regex++,
you need to embed "\\d+" in your code. Likewise to match a literal backslash
you will need to embed "\\\\" in your code.<FONT color="#ff0000">
</P>
<P>Q. Why does using parenthesis in a POSIX regular expression change the result
of a match?</FONT></P>
<P>For POSIX (extended and basic) regular expressions, but not for perl regexes,
parentheses don't only mark; they determine what the best match is as well.
When the expression is compiled as a POSIX basic or extended regex then
Boost.regex follows the POSIX standard leftmost longest rule for determining
what matched. So if there is more than one possible match after considering the
whole expression, it looks next at the first sub-expression and then the second
sub-expression and so on. So...</P>
<PRE>"(0*)([0-9]*)" against "00123" would produce
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<title>Boost.Regex: FAQ</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></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">FAQ</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>
<br>
<br>
<hr>
<font color="#ff0000"><font color="#ff0000"></font></font>
<p><font color="#ff0000"><font color="#ff0000"><font color=
"#ff0000">&nbsp;Q. Why can't I use the "convenience" versions of
regex_match / regex_search / regex_grep / regex_format /
regex_merge?</font></font></font></p>
<p>A. These versions may or may not be available depending upon the
capabilities of your compiler, the rules determining the format of
these functions are quite complex - and only the versions visible
to a standard compliant compiler are given in the help. To find out
what your compiler supports, run &lt;boost/regex.hpp&gt; through
your C++ pre-processor, and search the output file for the function
that you are interested in.<font color="#ff0000"><font color=
"#ff0000"></font></font></p>
<p><font color="#ff0000"><font color="#ff0000">Q. I can't get
regex++ to work with escape characters, what's going
on?</font></font></p>
<p>A. If you embed regular expressions in C++ code, then remember
that escape characters are processed twice: once by the C++
compiler, and once by the regex++ expression compiler, so to pass
the regular expression \d+ to regex++, you need to embed "\\d+" in
your code. Likewise to match a literal backslash you will need to
embed "\\\\" in your code. <font color="#ff0000"></font></p>
<p><font color="#ff0000">Q. Why does using parenthesis in a POSIX
regular expression change the result of a match?</font></p>
<p>For POSIX (extended and basic) regular expressions, but not for
perl regexes, parentheses don't only mark; they determine what the
best match is as well. When the expression is compiled as a POSIX
basic or extended regex then Boost.regex follows the POSIX standard
leftmost longest rule for determining what matched. So if there is
more than one possible match after considering the whole
expression, it looks next at the first sub-expression and then the
second sub-expression and so on. So...</p>
<pre>
"(0*)([0-9]*)" against "00123" would produce
$1 = "00"
$2 = "123"</PRE>
<P>where as</P>
<PRE>"0*([0-9)*" against "00123" would produce
$1 = "00123"</PRE>
<P>If you think about it, had $1 only matched the "123", this would be "less good"
than the match "00123" which is both further to the left and longer. If you
want $1 to match only the "123" part, then you need to use something like:</P>
<PRE>"0*([1-9][0-9]*)"</PRE>
<P>as the expression.</P>
<P><FONT color="#ff0000">Q. Why don't character ranges work properly (POSIX mode
only)?</FONT>
<BR>
A. The POSIX standard specifies that character range expressions are locale
sensitive - so for example the expression [A-Z] will match any collating
element that collates between 'A' and 'Z'. That means that for most locales
other than "C" or "POSIX", [A-Z] would match the single character 't' for
example, which is not what most people expect - or at least not what most
people have come to expect from regular expression engines. For this reason,
the default behaviour of boost.regex (perl mode) is to turn locale sensitive
collation off by not setting the regex_constants::collate compile time flag.
However if you set a non-default compile time flag - for example
regex_constants::extended or regex_constants::basic, then locale dependent
collation will be enabled, this also applies to the POSIX API functions which
use either regex_constants::extended or regex_constants::basic internally. <I>[Note
- when regex_constants::nocollate in effect, the library behaves "as if" the
LC_COLLATE locale category were always "C", regardless of what its actually set
to - end note</I>].
</P>
<P><FONT color="#ff0000">Q. Why are there no throw specifications on any of the
functions? What exceptions can the library throw?</FONT>
</P>
<P>
A. Not all compilers support (or honor) throw specifications, others support
them but with reduced efficiency. Throw specifications may be added at a later
date as compilers begin to handle this better. The library should throw only
three types of exception: boost::bad_expression can be thrown by basic_regex
when compiling a regular expression, std::runtime_error can be thrown when a
call to basic_regex::imbue tries to open a message catalogue that doesn't
exist, or when a call to regex_search or regex_match results in an
"everlasting" search,&nbsp;or when a call to RegEx::GrepFiles or
RegEx::FindFiles tries to open a file that cannot be opened, finally
std::bad_alloc can be thrown by just about any of the functions in this
library.
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
$2 = "123"
</pre>
<p>where as</p>
<pre>
"0*([0-9)*" against "00123" would produce
$1 = "00123"
</pre>
<p>If you think about it, had $1 only matched the "123", this would
be "less good" than the match "00123" which is both further to the
left and longer. If you want $1 to match only the "123" part, then
you need to use something like:</p>
<pre>
"0*([1-9][0-9]*)"
</pre>
<p>as the expression.</p>
<p><font color="#ff0000">Q. Why don't character ranges work
properly (POSIX mode only)?</font><br>
A. The POSIX standard specifies that character range expressions
are locale sensitive - so for example the expression [A-Z] will
match any collating element that collates between 'A' and 'Z'. That
means that for most locales other than "C" or "POSIX", [A-Z] would
match the single character 't' for example, which is not what most
people expect - or at least not what most people have come to
expect from regular expression engines. For this reason, the
default behaviour of boost.regex (perl mode) is to turn locale
sensitive collation off by not setting the regex_constants::collate
compile time flag. However if you set a non-default compile time
flag - for example regex_constants::extended or
regex_constants::basic, then locale dependent collation will be
enabled, this also applies to the POSIX API functions which use
either regex_constants::extended or regex_constants::basic
internally. <i>[Note - when regex_constants::nocollate in effect,
the library behaves "as if" the LC_COLLATE locale category were
always "C", regardless of what its actually set to - end
note</i>].</p>
<p><font color="#ff0000">Q. Why are there no throw specifications
on any of the functions? What exceptions can the library
throw?</font></p>
<p>A. Not all compilers support (or honor) throw specifications,
others support them but with reduced efficiency. Throw
specifications may be added at a later date as compilers begin to
handle this better. The library should throw only three types of
exception: boost::bad_expression can be thrown by basic_regex when
compiling a regular expression, std::runtime_error can be thrown
when a call to basic_regex::imbue tries to open a message catalogue
that doesn't exist, or when a call to regex_search or regex_match
results in an "everlasting" search,&nbsp;or when a call to
RegEx::GrepFiles or RegEx::FindFiles tries to open a file that
cannot be opened, finally std::bad_alloc can be thrown by just
about any of the functions in this library.</p>
<p></p>
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
<p><i>&copy; Copyright <a href="mailto:jm@regex.fsnet.co.uk">John
Maddock</a>&nbsp;1998-
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
<p align="left"><i>Permission to use, copy, modify, distribute and
sell this software and its documentation for any purpose is hereby
granted without fee, provided that the above copyright notice
appear in all copies and that both that copyright notice and this
permission notice appear in supporting documentation. Dr John
Maddock makes no representations about the suitability of this
software for any purpose. It is provided "as is" without express or
implied warranty.</i></p>
</body>
</html>

View File

@ -1,217 +1,272 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Format String Syntax</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">Format String Syntax</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>
<P>Format strings are used by the algorithm <A href="template_class_ref.htm#reg_merge">
regex_merge</A>&nbsp;and by <A href="match_results.html">match_results::format</A>,
and are used to transform one string into another.
</P>
<P>There are three kind of format string: sed, Perl and extended, the extended
syntax is a superset of the others so this is covered first.
</P>
<P><B><I>Extended format syntax</I></B>
</P>
<P>In format strings, all characters are treated as literals except: ()$\?:
</P>
<P>To use any of these as literals you must prefix them with the escape character
\
</P>
<P>The following special sequences are recognized:&nbsp;<BR>
&nbsp;
<BR>
<I>Grouping:</I>
</P>
<P>Use the parenthesis characters ( and ) to group sub-expressions within the
format string, use \( and \) to represent literal '(' and ')'.&nbsp;<BR>
&nbsp;
<BR>
<I>Sub-expression expansions:</I>
</P>
<P>The following Perl like expressions expand to a particular matched
sub-expression:
<BR>
&nbsp;
</P>
<P>
<TABLE id="Table2" cellSpacing="0" cellPadding="7" width="100%" border="0">
<TR>
<TD vAlign="top" width="8%">&nbsp;</TD>
<TD vAlign="top" width="40%">$`</TD>
<TD vAlign="top" width="43%">Expands to all the text from the end of the previous
match to the start of the current match, if there was no previous match in the
current operation, then everything from the start of the input string to the
start of the match.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="8%">&nbsp;</TD>
<TD vAlign="top" width="40%">$'</TD>
<TD vAlign="top" width="43%">Expands to all the text from the end of the match to
the end of the input string.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="8%">&nbsp;</TD>
<TD vAlign="top" width="40%">$&amp;</TD>
<TD vAlign="top" width="43%">Expands to all of the current match.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="8%">&nbsp;</TD>
<TD vAlign="top" width="40%">$0</TD>
<TD vAlign="top" width="43%">Expands to all of the current match.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="8%">&nbsp;</TD>
<TD vAlign="top" width="40%">$N</TD>
<TD vAlign="top" width="43%">Expands to the text that matched sub-expression <I>N</I>.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
</TABLE>
</P>
<P><I>Conditional expressions:</I>
</P>
<P>Conditional expressions allow two different format strings to be selected
dependent upon whether a sub-expression participated in the match or not:
</P>
<P>?Ntrue_expression:false_expression
</P>
<P>Executes true_expression if sub-expression <I>N</I> participated in the match,
otherwise executes false_expression.
</P>
<P>Example: suppose we search for "(while)|(for)" then the format string
"?1WHILE:FOR" would output what matched, but in upper case.&nbsp;<BR>
&nbsp;
<BR>
<I>Escape sequences:</I>
</P>
<P>The following escape sequences are also allowed:
<BR>
</P>
<P>
<TABLE id="Table3" cellSpacing="0" cellPadding="7" width="100%" border="0">
<TR>
<TD vAlign="top" width="8%">&nbsp;</TD>
<TD vAlign="top" width="40%">\a</TD>
<TD vAlign="top" width="43%">The bell character.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="8%">&nbsp;</TD>
<TD vAlign="top" width="40%">\f</TD>
<TD vAlign="top" width="43%">The form feed character.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="8%">&nbsp;</TD>
<TD vAlign="top" width="40%">\n</TD>
<TD vAlign="top" width="43%">The newline character.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="8%">&nbsp;</TD>
<TD vAlign="top" width="40%">\r</TD>
<TD vAlign="top" width="43%">The carriage return character.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="8%">&nbsp;</TD>
<TD vAlign="top" width="40%">\t</TD>
<TD vAlign="top" width="43%">The tab character.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="8%">&nbsp;</TD>
<TD vAlign="top" width="40%">\v</TD>
<TD vAlign="top" width="43%">A vertical tab character.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="8%">&nbsp;</TD>
<TD vAlign="top" width="40%">\x</TD>
<TD vAlign="top" width="43%">A hexadecimal character - for example \x0D.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="8%">&nbsp;</TD>
<TD vAlign="top" width="40%">\x{}</TD>
<TD vAlign="top" width="43%">A possible Unicode hexadecimal character - for
example \x{1A0}</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="8%">&nbsp;</TD>
<TD vAlign="top" width="40%">\cx</TD>
<TD vAlign="top" width="43%">The ASCII escape character x, for example \c@ is
equivalent to escape-@.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="8%">&nbsp;</TD>
<TD vAlign="top" width="40%">\e</TD>
<TD vAlign="top" width="43%">The ASCII escape character.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="8%">&nbsp;</TD>
<TD vAlign="top" width="40%">\dd</TD>
<TD vAlign="top" width="43%">An octal character constant, for example \10.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
</TABLE>
</P>
<P><B><I>Perl format strings</I></B>
</P>
<P>Perl format strings are the same as the default syntax except that the
characters ()?: have no special meaning.
</P>
<P><B><I>Sed format strings</I></B>
</P>
<P>Sed format strings use only the characters \ and &amp; as special characters.
</P>
<P>\n where n is a digit, is expanded to the nth sub-expression.
</P>
<P>&amp; is expanded to the whole of the match (equivalent to \0).
</P>
<P>
Other escape sequences are expanded as per the default syntax.
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<title>Boost.Regex: Format String Syntax</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></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">Format String Syntax</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>
<br>
<br>
<hr>
<p>Format strings are used by the algorithm <a href="template_class_ref.htm#reg_merge">regex_merge</a>&nbsp;and by <a
href="match_results.html">match_results::format</a>, and are used
to transform one string into another.</p>
<p>There are three kind of format string: sed, Perl and extended,
the extended syntax is a superset of the others so this is covered
first.</p>
<p><b><i>Extended format syntax</i></b></p>
<p>In format strings, all characters are treated as literals
except: ()$\?:</p>
<p>To use any of these as literals you must prefix them with the
escape character \</p>
<p>The following special sequences are recognized:&nbsp;<br>
&nbsp;<br>
<i>Grouping:</i></p>
<p>Use the parenthesis characters ( and ) to group sub-expressions
within the format string, use \( and \) to represent literal '('
and ')'.&nbsp;<br>
&nbsp;<br>
<i>Sub-expression expansions:</i></p>
<p>The following Perl like expressions expand to a particular
matched sub-expression:<br>
&nbsp;</p>
<p></p>
<table id="Table2" cellspacing="0" cellpadding="7" width="100%"
border="0">
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">$`</td>
<td valign="top" width="43%">Expands to all the text from the end
of the previous match to the start of the current match, if there
was no previous match in the current operation, then everything
from the start of the input string to the start of the match.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">$'</td>
<td valign="top" width="43%">Expands to all the text from the end
of the match to the end of the input string.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">$&amp;</td>
<td valign="top" width="43%">Expands to all of the current
match.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">$0</td>
<td valign="top" width="43%">Expands to all of the current
match.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">$N</td>
<td valign="top" width="43%">Expands to the text that matched
sub-expression <i>N</i>.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
</table>
<br>
<br>
<p><i>Conditional expressions:</i></p>
<p>Conditional expressions allow two different format strings to be
selected dependent upon whether a sub-expression participated in
the match or not:</p>
<p>?Ntrue_expression:false_expression</p>
<p>Executes true_expression if sub-expression <i>N</i> participated
in the match, otherwise executes false_expression.</p>
<p>Example: suppose we search for "(while)|(for)" then the format
string "?1WHILE:FOR" would output what matched, but in upper
case.&nbsp;<br>
&nbsp;<br>
<i>Escape sequences:</i></p>
<p>The following escape sequences are also allowed:<br>
</p>
<p></p>
<table id="Table3" cellspacing="0" cellpadding="7" width="100%"
border="0">
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">\a</td>
<td valign="top" width="43%">The bell character.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">\f</td>
<td valign="top" width="43%">The form feed character.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">\n</td>
<td valign="top" width="43%">The newline character.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">\r</td>
<td valign="top" width="43%">The carriage return character.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">\t</td>
<td valign="top" width="43%">The tab character.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">\v</td>
<td valign="top" width="43%">A vertical tab character.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">\x</td>
<td valign="top" width="43%">A hexadecimal character - for example
\x0D.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">\x{}</td>
<td valign="top" width="43%">A possible Unicode hexadecimal
character - for example \x{1A0}</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">\cx</td>
<td valign="top" width="43%">The ASCII escape character x, for
example \c@ is equivalent to escape-@.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">\e</td>
<td valign="top" width="43%">The ASCII escape character.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">\dd</td>
<td valign="top" width="43%">An octal character constant, for
example \10.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
</table>
<br>
<br>
<p><b><i>Perl format strings</i></b></p>
<p>Perl format strings are the same as the default syntax except
that the characters ()?: have no special meaning.</p>
<p><b><i>Sed format strings</i></b></p>
<p>Sed format strings use only the characters \ and &amp; as
special characters.</p>
<p>\n where n is a digit, is expanded to the nth
sub-expression.</p>
<p>&amp; is expanded to the whole of the match (equivalent to
\0).</p>
<p>Other escape sequences are expanded as per the default
syntax.</p>
<p></p>
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
<p><i>&copy; Copyright <a href="mailto:jm@regex.fsnet.co.uk">John
Maddock</a>&nbsp;1998-
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
<p align="left"><i>Permission to use, copy, modify, distribute and
sell this software and its documentation for any purpose is hereby
granted without fee, provided that the above copyright notice
appear in all copies and that both that copyright notice and this
permission notice appear in supporting documentation. Dr John
Maddock makes no representations about the suitability of this
software for any purpose. It is provided "as is" without express or
implied warranty.</i></p>
</body>
</html>

539
doc/gcc-performance.html Normal file
View File

@ -0,0 +1,539 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>Regular Expression Performance Comparison (gcc 3.2)</title>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<META content="C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\html.dot" name="Template">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
</head>
<body bgcolor="#ffffff" link="#0000ff" vlink="#800080">
<h2>Regular Expression Performance Comparison</h2>
<p>The following tables provide comparisons between the following regular
expression libraries:</p>
<p><a href="http://www.boost.org/">The Boost regex library</a>.</p>
<p><a href="http://www.gnu.org">The GNU regular expression library</a>.</p>
<p>Philip Hazel's <a href="http://www.pcre.org">PCRE</a> library.</p>
<h3>Details</h3>
<p>Machine: Intel Pentium 4 2.8GHz PC.</p>
<p>Compiler: GNU C++ version 3.2 20020927 (prerelease).</p>
<p>C++ Standard Library: GNU libstdc++ version 20020927.</p>
<p>OS: Cygwin.</p>
<p>Boost version: 1.31.0.</p>
<p>PCRE version: 4.1.</p>
<p>As ever care should be taken in interpreting the results, only sensible regular
expressions (rather than pathological cases) are given, most are taken from the
Boost regex examples, or from the <a href="http://www.regxlib.com/">Library of
Regular Expressions</a>. In addition, some variation in the relative
performance of these libraries can be expected on other machines - as memory
access and processor caching effects can be quite large for most finite state
machine algorithms. In each case the first figure given is the relative time
taken (so a value of 1.0 is as good as it gets), while the second figure is the
actual time taken.</p>
<h3>Averages</h3>
<p>The following are the average relative scores for all the tests: the perfect
regular expression library&nbsp;would score 1, in practice anything less than 2
is pretty good.</p>
<table border="1" cellspacing="1">
<tr>
<td><strong>Boost</strong></td>
<td><strong>Boost + C++ locale</strong></td>
<td><strong>POSIX</strong></td>
<td><strong>PCRE</strong></td>
</tr>
<tr>
<td>1.4503</td>
<td>1.49124</td>
<td>108.372</td>
<td>1.56255</td>
</tr>
</table>
<br>
<br>
<h3>Comparison 1: Long Search</h3>
<p>For each of the following regular expressions the time taken to find all
occurrences of the expression within a long English language text was measured
(<a href="ftp://ibiblio.org/pub/docs/books/gutenberg/etext02/mtent12.zip">mtent12.txt</a>
from <a href="http://promo.net/pg/">Project Gutenberg</a>, 19Mb).&nbsp;</p>
<table border="1" cellspacing="1">
<tr>
<td><strong>Expression</strong></td>
<td><strong>Boost</strong></td>
<td><strong>Boost + C++ locale</strong></td>
<td><strong>POSIX</strong></td>
<td><strong>PCRE</strong></td>
</tr>
<tr>
<td><code>Twain</code></td>
<td>3.49<br>
(0.205s)</td>
<td>4.09<br>
(0.24s)</td>
<td>65.2<br>
(3.83s)</td>
<td><font color="#008000">1<br>
(0.0588s)</font></td>
</tr>
<tr>
<td><code>Huck[[:alpha:]]+</code></td>
<td>3.86<br>
(0.203s)</td>
<td>4.52<br>
(0.238s)</td>
<td>100<br>
(5.26s)</td>
<td><font color="#008000">1<br>
(0.0526s)</font></td>
</tr>
<tr>
<td><code>[[:alpha:]]+ing</code></td>
<td><font color="#008000">1.01<br>
(1.23s)</font></td>
<td><font color="#008000">1<br>
(1.22s)</font></td>
<td>4.95<br>
(6.04s)</td>
<td>4.67<br>
(5.71s)</td>
</tr>
<tr>
<td><code>^[^ ]*?Twain</code></td>
<td><font color="#008000">1<br>
(0.31s)</font></td>
<td><font color="#008000">1.05<br>
(0.326s)</font></td>
<td>NA</td>
<td>3.32<br>
(1.03s)</td>
</tr>
<tr>
<td><code>Tom|Sawyer|Huckleberry|Finn</code></td>
<td><font color="#008000">1.02<br>
(0.125s)</font></td>
<td><font color="#008000">1<br>
(0.123s)</font></td>
<td>165<br>
(20.3s)</td>
<td><font color="#008000">1.08<br>
(0.133s)</font></td>
</tr>
<tr>
<td><code> (Tom|Sawyer|Huckleberry|Finn).{0,30}river|river.{0,30}(Tom|Sawyer|Huckleberry|Finn)</code></td>
<td><font color="#008000">1<br>
(0.345s)</font></td>
<td><font color="#008000">1.03<br>
(0.355s)</font></td>
<td>NA</td>
<td>1.71<br>
(0.59s)</td>
</tr>
</table>
<br>
<br>
<h3>Comparison 2: Medium Sized Search</h3>
<p>For each of the following regular expressions the time taken to find all
occurrences of the expression within a medium sized English language text was
measured (the first 50K from mtent12.txt).&nbsp;</p>
<table border="1" cellspacing="1">
<tr>
<td><strong>Expression</strong></td>
<td><strong>Boost</strong></td>
<td><strong>Boost + C++ locale</strong></td>
<td><strong>POSIX</strong></td>
<td><strong>PCRE</strong></td>
</tr>
<tr>
<td><code>Twain</code></td>
<td>1.8<br>
(0.000519s)</td>
<td>2.14<br>
(0.000616s)</td>
<td>9.08<br>
(0.00262s)</td>
<td><font color="#008000">1<br>
(0.000289s)</font></td>
</tr>
<tr>
<td><code>Huck[[:alpha:]]+</code></td>
<td>3.65<br>
(0.000499s)</td>
<td>4.36<br>
(0.000597s)</td>
<td><font color="#008000">1<br>
(0.000137s)</font></td>
<td>1.43<br>
(0.000196s)</td>
</tr>
<tr>
<td><code>[[:alpha:]]+ing</code></td>
<td><font color="#008000">1<br>
(0.00258s)</font></td>
<td><font color="#008000">1<br>
(0.00258s)</font></td>
<td>5.28<br>
(0.0136s)</td>
<td>5.63<br>
(0.0145s)</td>
</tr>
<tr>
<td><code>^[^ ]*?Twain</code></td>
<td><font color="#008000">1<br>
(0.000929s)</font></td>
<td><font color="#008000">1.03<br>
(0.000957s)</font></td>
<td>NA</td>
<td>2.82<br>
(0.00262s)</td>
</tr>
<tr>
<td><code>Tom|Sawyer|Huckleberry|Finn</code></td>
<td><font color="#008000">1<br>
(0.000812s)</font></td>
<td><font color="#008000">1<br>
(0.000812s)</font></td>
<td>60.1<br>
(0.0488s)</td>
<td>1.28<br>
(0.00104s)</td>
</tr>
<tr>
<td><code> (Tom|Sawyer|Huckleberry|Finn).{0,30}river|river.{0,30}(Tom|Sawyer|Huckleberry|Finn)</code></td>
<td><font color="#008000">1.02<br>
(0.00178s)</font></td>
<td><font color="#008000">1<br>
(0.00174s)</font></td>
<td>242<br>
(0.421s)</td>
<td>1.3<br>
(0.00227s)</td>
</tr>
</table>
<br>
<br>
<h3>Comparison 3:&nbsp;C++ Code&nbsp;Search</h3>
<p>For each of the following regular expressions the time taken to find all
occurrences of the expression within the C++ source file <a href="../../../boost/crc.hpp">
boost/crc.hpp</a>&nbsp;was measured.&nbsp;</p>
<table border="1" cellspacing="1">
<tr>
<td><strong>Expression</strong></td>
<td><strong>Boost</strong></td>
<td><strong>Boost + C++ locale</strong></td>
<td><strong>POSIX</strong></td>
<td><strong>PCRE</strong></td>
</tr>
<tr>
<td><code> ^(template[[:space:]]*&lt;[^;:{]+&gt;[[:space:]]*)?(class|struct)[[:space:]]*(\&lt;\w+\&gt;([
]*\([^)]*\))?[[:space:]]*)*(\&lt;\w*\&gt;)[[:space:]]*(&lt;[^;:{]+&gt;[[:space:]]*)?(\{|:[^;\{()]*\{)</code></td>
<td><font color="#008000">1.04<br>
(0.000144s)</font></td>
<td><font color="#008000">1<br>
(0.000139s)</font></td>
<td>862<br>
(0.12s)</td>
<td>4.56<br>
(0.000636s)</td>
</tr>
<tr>
<td><code>(^[
]*#(?:[^\\\n]|\\[^\n_[:punct:][:alnum:]]*[\n[:punct:][:word:]])*)|(//[^\n]*|/\*.*?\*/)|\&lt;([+-]?(?:(?:0x[[:xdigit:]]+)|(?:(?:[[:digit:]]*\.)?[[:digit:]]+(?:[eE][+-]?[[:digit:]]+)?))u?(?:(?:int(?:8|16|32|64))|L)?)\&gt;|('(?:[^\\']|\\.)*'|"(?:[^\\"]|\\.)*")|\&lt;(__asm|__cdecl|__declspec|__export|__far16|__fastcall|__fortran|__import|__pascal|__rtti|__stdcall|_asm|_cdecl|__except|_export|_far16|_fastcall|__finally|_fortran|_import|_pascal|_stdcall|__thread|__try|asm|auto|bool|break|case|catch|cdecl|char|class|const|const_cast|continue|default|delete|do|double|dynamic_cast|else|enum|explicit|extern|false|float|for|friend|goto|if|inline|int|long|mutable|namespace|new|operator|pascal|private|protected|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_cast|struct|switch|template|this|throw|true|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while)\&gt;</code></td>
<td><font color="#008000">1<br>
(0.0139s)</font></td>
<td><font color="#008000">1.01<br>
(0.0141s)</font></td>
<td>NA</td>
<td>1.55<br>
(0.0216s)</td>
</tr>
<tr>
<td><code>^[ ]*#[ ]*include[ ]+("[^"]+"|&lt;[^&gt;]+&gt;)</code></td>
<td><font color="#008000">1.04<br>
(0.000332s)</font></td>
<td><font color="#008000">1<br>
(0.000318s)</font></td>
<td>130<br>
(0.0413s)</td>
<td>1.72<br>
(0.000547s)</td>
</tr>
<tr>
<td><code>^[ ]*#[ ]*include[ ]+("boost/[^"]+"|&lt;boost/[^&gt;]+&gt;)</code></td>
<td><font color="#008000">1.02<br>
(0.000323s)</font></td>
<td><font color="#008000">1<br>
(0.000318s)</font></td>
<td>150<br>
(0.0476s)</td>
<td>1.72<br>
(0.000547s)</td>
</tr>
</table>
<br>
<h3></h3>
<H3>Comparison 4: HTML Document Search
</H3>
<p>For each of the following regular expressions the time taken to find all
occurrences of the expression within the html file <a href="../../libraries.htm">libs/libraries.htm</a>
was measured.&nbsp;</p>
<table border="1" cellspacing="1">
<tr>
<td><strong>Expression</strong></td>
<td><strong>Boost</strong></td>
<td><strong>Boost + C++ locale</strong></td>
<td><strong>POSIX</strong></td>
<td><strong>PCRE</strong></td>
</tr>
<tr>
<td><code>beman|john|dave</code></td>
<td><font color="#008000">1.03<br>
(0.000367s)</font></td>
<td><font color="#008000">1<br>
(0.000357s)</font></td>
<td>47.4<br>
(0.0169s)</td>
<td>1.16<br>
(0.000416s)</td>
</tr>
<tr>
<td><code>&lt;p&gt;.*?&lt;/p&gt;</code></td>
<td>1.25<br>
(0.000459s)</td>
<td><font color="#008000">1<br>
(0.000367s)</font></td>
<td>NA</td>
<td><font color="#008000">1.03<br>
(0.000376s)</font></td>
</tr>
<tr>
<td><code> &lt;a[^&gt;]+href=("[^"]*"|[^[:space:]]+)[^&gt;]*&gt;</code></td>
<td><font color="#008000">1<br>
(0.000509s)</font></td>
<td><font color="#008000">1.02<br>
(0.000518s)</font></td>
<td>305<br>
(0.155s)</td>
<td><font color="#008000">1.1<br>
(0.000558s)</font></td>
</tr>
<tr>
<td><code> &lt;h[12345678][^&gt;]*&gt;.*?&lt;/h[12345678]&gt;</code></td>
<td><font color="#008000">1.04<br>
(0.00025s)</font></td>
<td><font color="#008000">1<br>
(0.00024s)</font></td>
<td>NA</td>
<td>1.16<br>
(0.000279s)</td>
</tr>
<tr>
<td><code> &lt;img[^&gt;]+src=("[^"]*"|[^[:space:]]+)[^&gt;]*&gt;</code></td>
<td>2.22<br>
(0.000489s)</td>
<td>1.69<br>
(0.000372s)</td>
<td>148<br>
(0.0326s)</td>
<td><font color="#008000">1<br>
(0.00022s)</font></td>
</tr>
<tr>
<td><code> &lt;font[^&gt;]+face=("[^"]*"|[^[:space:]]+)[^&gt;]*&gt;.*?&lt;/font&gt;</code></td>
<td>1.71<br>
(0.000371s)</td>
<td>1.75<br>
(0.000381s)</td>
<td>NA</td>
<td><font color="#008000">1<br>
(0.000218s)</font></td>
</tr>
</table>
<br>
<br>
<h3>Comparison 3: Simple Matches</h3>
<p>For each of the following regular expressions the time taken to match against
the text indicated was measured.&nbsp;</p>
<table border="1" cellspacing="1">
<tr>
<td><strong>Expression</strong></td>
<td><strong>Text</strong></td>
<td><strong>Boost</strong></td>
<td><strong>Boost + C++ locale</strong></td>
<td><strong>POSIX</strong></td>
<td><strong>PCRE</strong></td>
</tr>
<tr>
<td><code>abc</code></td>
<td>abc</td>
<td>1.36<br>
(2.15e-07s)</td>
<td>1.36<br>
(2.15e-07s)</td>
<td>2.76<br>
(4.34e-07s)</td>
<td><font color="#008000">1<br>
(1.58e-07s)</font></td>
</tr>
<tr>
<td><code>^([0-9]+)(\-| |$)(.*)$</code></td>
<td>100- this is a line of ftp response which contains a message string</td>
<td>1.55<br>
(7.26e-07s)</td>
<td>1.51<br>
(7.07e-07s)</td>
<td>319<br>
(0.000149s)</td>
<td><font color="#008000">1<br>
(4.67e-07s)</font></td>
</tr>
<tr>
<td><code>([[:digit:]]{4}[- ]){3}[[:digit:]]{3,4}</code></td>
<td>1234-5678-1234-456</td>
<td>1.96<br>
(9.54e-07s)</td>
<td>1.96<br>
(9.54e-07s)</td>
<td>44.5<br>
(2.17e-05s)</td>
<td><font color="#008000">1<br>
(4.87e-07s)</font></td>
</tr>
<tr>
<td><code> ^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$</code></td>
<td>john_maddock@compuserve.com</td>
<td>1.22<br>
(1.51e-06s)</td>
<td>1.23<br>
(1.53e-06s)</td>
<td>162<br>
(0.000201s)</td>
<td><font color="#008000">1<br>
(1.24e-06s)</font></td>
</tr>
<tr>
<td><code> ^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$</code></td>
<td>foo12@foo.edu</td>
<td>1.28<br>
(1.47e-06s)</td>
<td>1.3<br>
(1.49e-06s)</td>
<td>104<br>
(0.00012s)</td>
<td><font color="#008000">1<br>
(1.15e-06s)</font></td>
</tr>
<tr>
<td><code> ^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$</code></td>
<td>bob.smith@foo.tv</td>
<td>1.28<br>
(1.47e-06s)</td>
<td>1.3<br>
(1.49e-06s)</td>
<td>113<br>
(0.00013s)</td>
<td><font color="#008000">1<br>
(1.15e-06s)</font></td>
</tr>
<tr>
<td><code>^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$</code></td>
<td>EH10 2QQ</td>
<td>1.38<br>
(4.68e-07s)</td>
<td>1.41<br>
(4.77e-07s)</td>
<td>13.5<br>
(4.59e-06s)</td>
<td><font color="#008000">1<br>
(3.39e-07s)</font></td>
</tr>
<tr>
<td><code>^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$</code></td>
<td>G1 1AA</td>
<td>1.28<br>
(4.35e-07s)</td>
<td>1.25<br>
(4.25e-07s)</td>
<td>11.7<br>
(3.97e-06s)</td>
<td><font color="#008000">1<br>
(3.39e-07s)</font></td>
</tr>
<tr>
<td><code>^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$</code></td>
<td>SW1 1ZZ</td>
<td>1.32<br>
(4.53e-07s)</td>
<td>1.31<br>
(4.49e-07s)</td>
<td>12.2<br>
(4.2e-06s)</td>
<td><font color="#008000">1<br>
(3.44e-07s)</font></td>
</tr>
<tr>
<td><code> ^[[:digit:]]{1,2}/[[:digit:]]{1,2}/[[:digit:]]{4}$</code></td>
<td>4/1/2001</td>
<td>1.16<br>
(3.82e-07s)</td>
<td>1.2<br>
(3.96e-07s)</td>
<td>13.9<br>
(4.59e-06s)</td>
<td><font color="#008000">1<br>
(3.29e-07s)</font></td>
</tr>
<tr>
<td><code> ^[[:digit:]]{1,2}/[[:digit:]]{1,2}/[[:digit:]]{4}$</code></td>
<td>12/12/2001</td>
<td>1.38<br>
(4.49e-07s)</td>
<td>1.38<br>
(4.49e-07s)</td>
<td>16<br>
(5.2e-06s)</td>
<td><font color="#008000">1<br>
(3.25e-07s)</font></td>
</tr>
<tr>
<td><code>^[-+]?[[:digit:]]*\.?[[:digit:]]*$</code></td>
<td>123</td>
<td>1.19<br>
(7.64e-07s)</td>
<td>1.16<br>
(7.45e-07s)</td>
<td>7.51<br>
(4.81e-06s)</td>
<td><font color="#008000">1<br>
(6.4e-07s)</font></td>
</tr>
<tr>
<td><code>^[-+]?[[:digit:]]*\.?[[:digit:]]*$</code></td>
<td>+3.14159</td>
<td>1.32<br>
(8.97e-07s)</td>
<td>1.31<br>
(8.88e-07s)</td>
<td>14<br>
(9.48e-06s)</td>
<td><font color="#008000">1<br>
(6.78e-07s)</font></td>
</tr>
<tr>
<td><code>^[-+]?[[:digit:]]*\.?[[:digit:]]*$</code></td>
<td>-3.14159</td>
<td>1.32<br>
(8.97e-07s)</td>
<td>1.31<br>
(8.88e-07s)</td>
<td>14<br>
(9.48e-06s)</td>
<td><font color="#008000">1<br>
(6.78e-07s)</font></td>
</tr>
</table>
<br>
<br>
<hr>
<p>Copyright John Maddock April 2003, all rights reserved.</p>
</body>
</html>

View File

@ -37,7 +37,7 @@
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
@ -49,3 +49,4 @@
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -43,7 +43,7 @@
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
@ -55,3 +55,4 @@
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -30,7 +30,7 @@
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
@ -42,3 +42,4 @@
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -18,7 +18,7 @@
<h2 align="center">Index</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" width="43" alt="Boost Libraries Index" src="uarrow.gif" border="0"></a></h3>
</td>
</tr>
</table>
@ -100,6 +100,7 @@
<dt><a href="redistributables.html">Redistributables and Library Names</a></dt>
<dt><a href="standards.html">Standards Conformance</a></dt>
<dt><a href="history.html">History</a></dt>
<dt><a href="performance.html">Performance</a></dt>
<dt><a href="contacts.html">Contacts and Acknowledgements</a></dt>
</dl>
</dd>
@ -107,7 +108,7 @@
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
<p><i>&copy; Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
@ -122,3 +123,5 @@
</body>
</html>

View File

@ -222,7 +222,7 @@
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
@ -234,3 +234,4 @@
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -159,7 +159,7 @@ std::string human_readable_card_number(<B>const</B> std::string s)
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
@ -173,3 +173,4 @@ std::string human_readable_card_number(<B>const</B> std::string s)
</html>

File diff suppressed because it is too large Load Diff

View File

@ -1,34 +1,47 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: match_flag_type</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">match_flag_type</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>
<H3>Synopsis</H3>
<P>The type <CODE>match_flag_type</CODE> is an implementation defined bitmask type
(17.3.2.1.2) that controls how a regular expression is matched against a
character sequence.</P>
<PRE>namespace std{ namespace regex_constants{
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<title>Boost.Regex: match_flag_type</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></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">match_flag_type</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>
<br>
<br>
<hr>
<h3>Synopsis</h3>
<p>The type <code>match_flag_type</code> is an implementation
defined bitmask type (17.3.2.1.2) that controls how a regular
expression is matched against a character sequence.</p>
<pre>
namespace std{ namespace regex_constants{
typedef bitmask_type match_flag_type;
@ -55,212 +68,263 @@ static const match_flag_type format_first_only;
static const match_flag_type format_all;
} // namespace regex_constants
} // namespace std</PRE>
<H3>Description</H3>
<P>The type <CODE>match_flag_type</CODE> is an implementation defined bitmask type
(17.3.2.1.2). When matching a regular expression against a sequence of
characters [first, last) then setting its elements has the effects listed in
the table below:</P>
<P>
<TABLE id="Table2" cellSpacing="1" cellPadding="7" width="100%" border="0">
<TR>
<TD vAlign="top" width="50%">
<P>Element</P>
</TD>
<TD vAlign="top" width="50%">
<P>Effect if set</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>match_default</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that matching of regular expressions proceeds without any
modification of the normal rules used in ECMA-262, ECMAScript Language
Specification, Chapter 15 part 10, RegExp (Regular Expression) Objects (FWD.1)</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">match_not_bob</TD>
<TD vAlign="top" width="50%">Specifies that the expression "\A" should not match
against the sub-sequence [first,first).</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">match_not_eob</TD>
<TD vAlign="top" width="50%">Specifies that the expressions "\z" and
"\Z"&nbsp;should not match against the sub-sequence [last,last).</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>match_not_bol</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that the expression "^" should not be matched against the
sub-sequence [first,first).</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>match_not_eol</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that the expression "$" should not be matched against the
sub-sequence [last,last).</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>match_not_bow</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that the expression "\b" should not be matched against the
sub-sequence [first,first).</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>match_not_eow</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that the expression "\b" should not be matched against the
sub-sequence [last,last).</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>match_any</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that if more than one match is possible then any match is an
acceptable result.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>match_not_null</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that the expression can not be matched against an empty sequence.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>match_continuous</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that the expression must match a sub-sequence that begins at <I>first</I>.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>match_partial</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that if no match can be found, then it is acceptable to return a
match [from, last) where from!=last, if there exists some sequence of
characters [from,to) of which [from,last) is a prefix, and which would result
in a full match.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>match_prev_avail</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that <CODE>--first</CODE> is a valid iterator position, when this
flag is set then the flags <CODE>match_not_bol</CODE> and <CODE>match_not_bow</CODE>
are ignored by the regular expression algorithms (RE.7) and iterators (RE.8).</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">match_not_dot_newline</TD>
<TD vAlign="top" width="50%">Specifies that the expression "." does not match a
newline character.</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">match_not_dot_null</TD>
<TD vAlign="top" width="50%">Specified that the expression "." does not match a
character null '\0'.</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>format_default</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that when a regular expression match is to be replaced by a new
string, that the new string is constructed using the rules used by the
ECMAScript replace function in ECMA-262, ECMAScript Language Specification,
Chapter 15 part 5.4.11 String.prototype.replace. (FWD.1). In addition during
search and replace operations then all non-overlapping occurrences of the
regular expression are located and replaced, and sections of the input that did
not match the expression, are copied unchanged to the output string.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>format_sed</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that when a regular expression match is to be replaced by a new
string, that the new string is constructed using the rules used by the Unix sed
utility in IEEE Std 1003.1-2001, Portable Operating SystemInterface (POSIX ),
Shells and Utilities..</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>format_perl</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that when a regular expression match is to be replaced by a new
string, that the new string is constructed using an implementation defined
superset of the rules used by the ECMAScript replace function in ECMA-262,
ECMAScript Language Specification, Chapter 15 part 5.4.11
String.prototype.replace (FWD.1).</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%" height="32">format_all</TD>
<TD vAlign="top" width="50%" height="32">Specifies that all syntax extensions are
enabled, including conditional (?ddexpression1:expression2) replacements.</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>format_no_copy</P>
</TD>
<TD vAlign="top" width="50%">
<P>When specified during a search and replace operation, then sections of the
character container sequence being searched that do match the regular
expression, are not copied to the output string.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>format_first_only</P>
</TD>
<TD vAlign="top" width="50%">
<P>When specified during a search and replace operation, then only the first
occurrence of the regular expression is replaced.</P>
</TD>
</TR>
</TABLE>
</P>
<P>
<HR>
</P>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
} // namespace std
</pre>
<h3>Description</h3>
<p>The type <code>match_flag_type</code> is an implementation
defined bitmask type (17.3.2.1.2). When matching a regular
expression against a sequence of characters [first, last) then
setting its elements has the effects listed in the table below:</p>
<p></p>
<table id="Table2" cellspacing="1" cellpadding="7" width="100%"
border="0">
<tr>
<td valign="top" width="50%">
<p>Element</p>
</td>
<td valign="top" width="50%">
<p>Effect if set</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>match_default</p>
</td>
<td valign="top" width="50%">
<p>Specifies that matching of regular expressions proceeds without
any modification of the normal rules used in ECMA-262, ECMAScript
Language Specification, Chapter 15 part 10, RegExp (Regular
Expression) Objects (FWD.1)</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">match_not_bob</td>
<td valign="top" width="50%">Specifies that the expression "\A"
should not match against the sub-sequence [first,first).</td>
</tr>
<tr>
<td valign="top" width="50%">match_not_eob</td>
<td valign="top" width="50%">Specifies that the expressions "\z"
and "\Z"&nbsp;should not match against the sub-sequence
[last,last).</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>match_not_bol</p>
</td>
<td valign="top" width="50%">
<p>Specifies that the expression "^" should not be matched against
the sub-sequence [first,first).</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>match_not_eol</p>
</td>
<td valign="top" width="50%">
<p>Specifies that the expression "$" should not be matched against
the sub-sequence [last,last).</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>match_not_bow</p>
</td>
<td valign="top" width="50%">
<p>Specifies that the expression "\b" should not be matched against
the sub-sequence [first,first).</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>match_not_eow</p>
</td>
<td valign="top" width="50%">
<p>Specifies that the expression "\b" should not be matched against
the sub-sequence [last,last).</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>match_any</p>
</td>
<td valign="top" width="50%">
<p>Specifies that if more than one match is possible then any match
is an acceptable result.</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>match_not_null</p>
</td>
<td valign="top" width="50%">
<p>Specifies that the expression can not be matched against an
empty sequence.</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>match_continuous</p>
</td>
<td valign="top" width="50%">
<p>Specifies that the expression must match a sub-sequence that
begins at <i>first</i>.</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>match_partial</p>
</td>
<td valign="top" width="50%">
<p>Specifies that if no match can be found, then it is acceptable
to return a match [from, last) where from!=last, if there exists
some sequence of characters [from,to) of which [from,last) is a
prefix, and which would result in a full match.</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>match_prev_avail</p>
</td>
<td valign="top" width="50%">
<p>Specifies that <code>--first</code> is a valid iterator
position, when this flag is set then the flags <code>
match_not_bol</code> and <code>match_not_bow</code> are ignored by
the regular expression algorithms (RE.7) and iterators (RE.8).</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">match_not_dot_newline</td>
<td valign="top" width="50%">Specifies that the expression "." does
not match a newline character.</td>
</tr>
<tr>
<td valign="top" width="50%">match_not_dot_null</td>
<td valign="top" width="50%">Specified that the expression "." does
not match a character null '\0'.</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>format_default</p>
</td>
<td valign="top" width="50%">
<p>Specifies that when a regular expression match is to be replaced
by a new string, that the new string is constructed using the rules
used by the ECMAScript replace function in ECMA-262, ECMAScript
Language Specification, Chapter 15 part 5.4.11
String.prototype.replace. (FWD.1). In addition during search and
replace operations then all non-overlapping occurrences of the
regular expression are located and replaced, and sections of the
input that did not match the expression, are copied unchanged to
the output string.</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>format_sed</p>
</td>
<td valign="top" width="50%">
<p>Specifies that when a regular expression match is to be replaced
by a new string, that the new string is constructed using the rules
used by the Unix sed utility in IEEE Std 1003.1-2001, Portable
Operating SystemInterface (POSIX ), Shells and Utilities..</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>format_perl</p>
</td>
<td valign="top" width="50%">
<p>Specifies that when a regular expression match is to be replaced
by a new string, that the new string is constructed using an
implementation defined superset of the rules used by the ECMAScript
replace function in ECMA-262, ECMAScript Language Specification,
Chapter 15 part 5.4.11 String.prototype.replace (FWD.1).</p>
</td>
</tr>
<tr>
<td valign="top" width="50%" height="32">format_all</td>
<td valign="top" width="50%" height="32">Specifies that all syntax
extensions are enabled, including conditional
(?ddexpression1:expression2) replacements.</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>format_no_copy</p>
</td>
<td valign="top" width="50%">
<p>When specified during a search and replace operation, then
sections of the character container sequence being searched that do
match the regular expression, are not copied to the output
string.</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>format_first_only</p>
</td>
<td valign="top" width="50%">
<p>When specified during a search and replace operation, then only
the first occurrence of the regular expression is replaced.</p>
</td>
</tr>
</table>
<br>
<br>
<p></p>
<hr>
<br>
<br>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
<p><i>&copy; Copyright <a href="mailto:jm@regex.fsnet.co.uk">John
Maddock</a>&nbsp;1998-
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
<p align="left"><i>Permission to use, copy, modify, distribute and
sell this software and its documentation for any purpose is hereby
granted without fee, provided that the above copyright notice
appear in all copies and that both that copyright notice and this
permission notice appear in supporting documentation. Dr John
Maddock makes no representations about the suitability of this
software for any purpose. It is provided "as is" without express or
implied warranty.</i></p>
</body>
</html>

View File

@ -1,57 +1,78 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: class match_results</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">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>
</td>
</TR>
</TABLE>
</P>
<HR>
<H3>Contents</H3>
<DL class="index">
<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>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>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">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>The template class match_results conforms to the requirements of a Sequence, as
specified in (lib.sequence.reqmts), except that only operations defined for
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,
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<title>Boost.Regex: class match_results</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></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">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>
</td>
</tr>
</table>
<br>
<br>
<hr>
<h3>Contents</h3>
<dl class="index">
<dt><a href="#synopsis">Synopsis</a></dt>
<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>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>
<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">
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 specified in (lib.sequence.reqmts), except that only
operations defined for 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,
class Allocator = allocator&lt;sub_match&lt;BidirectionalIterator&gt; &gt;
class match_results;
@ -123,260 +144,368 @@ basic_ostream&lt;charT, traits&gt;&amp;
template &lt;class BidirectionalIterator, class Allocator&gt;
void swap(match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m1,
match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m2);</PRE>
<H3><A name="description"></A>Description</H3>
<H4>match_results constructors</H4>
<P>In all <CODE>match_results</CODE> constructors, a copy of the Allocator
argument is used for any memory allocation performed by the constructor or
member functions during the lifetime of the object.
</P>
<PRE>match_results(const Allocator&amp; a = Allocator());</PRE>
<B>
<P>
Effects:</B> Constructs an object of class match_results. The postconditions
of this function are indicated in the table:</P>
<P align="center">
<CENTER>
<TABLE id="Table2" cellSpacing="1" cellPadding="7" width="624" border="1">
<TBODY>
<TR>
<TD vAlign="top" width="50%"><B>
<P>
Element</B>
</P>
</TD>
<TD vAlign="top" width="50%"><B>
<P>
Value</B> </P></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>empty()</P>
</TD>
<TD vAlign="top" width="50%">
<P>true</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>size()</P>
</TD>
<TD vAlign="top" width="50%">
<P>0</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>str()</P>
</TD>
<TD vAlign="top" width="50%">
<P>basic_string&lt;charT&gt;()</P>
<P></P>
</TD>
</TR>
</TBODY></TD></TR></TABLE></CENTER>
<P></P>
<DIV></DIV>
<P>&nbsp;</P>
<PRE>match_results(const match_results&amp; m);</PRE>
<B>
<P>
Effects:</B> Constructs an object of class match_results, as a copy of
m.</P><PRE>match_results&amp; operator=(const match_results&amp; m);</PRE>
<B>
<P>
Effects:</B> Assigns m to *this. The postconditions of this function are
indicated in the table:</P>
<P align="center">
<CENTER>
<TABLE id="Table3" cellSpacing="1" cellPadding="7" width="624" border="1">
<TBODY>
<TR>
<TD vAlign="top" width="50%"><B>
<P>
Element</B>
</P>
</TD>
<TD vAlign="top" width="50%"><B>
<P>
Value</B> </P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>empty()</P>
</TD>
<TD vAlign="top" width="50%">
<P>m.empty().</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>size()</P>
</TD>
<TD vAlign="top" width="50%">
<P>m.size().</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>str(n)</P>
</TD>
<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%">
<P>prefix()</P>
</TD>
<TD vAlign="top" width="50%">
<P>m.prefix().</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>suffix()</P>
</TD>
<TD vAlign="top" width="50%">
<P>m.suffix().</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>(*this)[n]</P>
</TD>
<TD vAlign="top" width="50%">
<P>m[n] for all integers n &lt; m.size().</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>length(n)</P>
</TD>
<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%">
<P>position(n)</P>
</TD>
<TD vAlign="top" width="50%">
<P>m.position(n) for all integers n &lt; m.size().</P>
<P></P>
</TD>
</TR>
</TBODY></TD></TR></TABLE></CENTER>
<P></P>
<DIV></DIV>
<H4>match_results size</H4>
<PRE>size_type size()const;</PRE>
<B>
<P>
Effects:</B> Returns the number of sub_match elements stored in *this.</P><PRE>size_type max_size()const;</PRE>
<B>
<P>
Effects:</B> Returns the maximum number of sub_match elements that can be
stored in *this.</P><PRE>bool empty()const;</PRE>
<B>
<P>
Effects:</B> Returns <CODE>size() == 0</CODE>.</P>
<H4>match_results element access</H4>
<PRE>difference_type length(int sub = 0)const;</PRE>
<B>
<P>
Effects:</B> Returns <CODE>(*this)[sub].length()</CODE>.</P><PRE>difference_type position(unsigned int sub = 0)const;</PRE>
<B>
<P>
Effects:</B> Returns <CODE>std::distance(prefix().first,
(*this)[sub].first).</P></CODE><PRE>string_type str(int sub = 0)const;</PRE>
<B>
<P>
Effects:</B> Returns <CODE>string_type((*this)[sub]).</P></CODE><PRE>const_reference operator[](int n) const;</PRE>
<B>
<P>
Effects:</B> Returns a reference to the <CODE>sub_match </CODE>object
representing the character sequence that matched marked sub-expression <I>n</I>.
If <CODE>n == 0 </CODE>then returns a reference to a <CODE>sub_match</CODE> object
representing the character sequence that matched the whole regular
expression.</P><PRE>const_reference prefix()const;</PRE>
<B>
<P>
Effects:</B> Returns a reference to the <CODE>sub_match </CODE>object
representing the character sequence from the start of the string being
matched/searched, to the start of the match found.</P><PRE>const_reference suffix()const;</PRE>
<B>
<P>
Effects:</B> Returns a reference to the <CODE>sub_match </CODE>object
representing the character sequence from the end of the match found to the end
of the string being matched/searched.</P><PRE>const_iterator begin()const;</PRE>
<B>
<P>
Effects:</B> Returns a starting iterator that enumerates over all the marked
sub-expression matches stored in *this.</P><PRE>const_iterator end()const;</PRE>
<B>
<P>
Effects:</B> Returns a terminating iterator that enumerates over all the
marked sub-expression matches stored in *this.</P>
<H4>match_results reformatting</H4>
<PRE>template &lt;class OutputIterator&gt;
match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m2);
</pre>
<h3><a name="description"></a>Description</h3>
<h4>match_results constructors</h4>
<p>In all <code>match_results</code> constructors, a copy of the
Allocator argument is used for any memory allocation performed by
the constructor or member functions during the lifetime of the
object.</p>
<pre>
match_results(const Allocator&amp; a = Allocator());
</pre>
<b></b>
<p><b>Effects:</b> Constructs an object of class match_results. The
postconditions 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">
<tbody>
<tr>
<td valign="top" width="50%"><b></b>
<p><b>Element</b></p>
</td>
<td valign="top" width="50%"><b></b>
<p><b>Value</b></p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>empty()</p>
</td>
<td valign="top" width="50%">
<p>true</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>size()</p>
</td>
<td valign="top" width="50%">
<p>0</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>str()</p>
</td>
<td valign="top" width="50%">
<p>basic_string&lt;charT&gt;()</p>
</td>
</tr>
</tbody>
</table>
</center>
<p>&nbsp;</p>
<pre>
match_results(const match_results&amp; m);
</pre>
<b></b>
<p><b>Effects:</b> Constructs an object of class match_results, as
a copy of m.</p>
<pre>
match_results&amp; operator=(const match_results&amp; m);
</pre>
<b></b>
<p><b>Effects:</b> Assigns m to *this. The postconditions of this
function are indicated in the table:</p>
<p align="center"></p>
<center>
<table id="Table3" cellspacing="1" cellpadding="7" width="624"
border="1">
<tbody>
<tr>
<td valign="top" width="50%"><b></b>
<p><b>Element</b></p>
</td>
<td valign="top" width="50%"><b></b>
<p><b>Value</b></p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>empty()</p>
</td>
<td valign="top" width="50%">
<p>m.empty().</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>size()</p>
</td>
<td valign="top" width="50%">
<p>m.size().</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>str(n)</p>
</td>
<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%">
<p>prefix()</p>
</td>
<td valign="top" width="50%">
<p>m.prefix().</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>suffix()</p>
</td>
<td valign="top" width="50%">
<p>m.suffix().</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>(*this)[n]</p>
</td>
<td valign="top" width="50%">
<p>m[n] for all integers n &lt; m.size().</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>length(n)</p>
</td>
<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%">
<p>position(n)</p>
</td>
<td valign="top" width="50%">
<p>m.position(n) for all integers n &lt; m.size().</p>
</td>
</tr>
</tbody>
</table>
</center>
<h4>match_results size</h4>
<pre>
size_type size()const;
</pre>
<b></b>
<p><b>Effects:</b> Returns the number of sub_match elements stored
in *this.</p>
<pre>
size_type max_size()const;
</pre>
<b></b>
<p><b>Effects:</b> Returns the maximum number of sub_match elements
that can be stored in *this.</p>
<pre>
bool empty()const;
</pre>
<b></b>
<p><b>Effects:</b> Returns <code>size() == 0</code>.</p>
<h4>match_results element access</h4>
<pre>
difference_type length(int sub = 0)const;
</pre>
<b></b>
<p><b>Effects:</b> Returns <code>(*this)[sub].length()</code>.</p>
<pre>
difference_type position(unsigned int sub = 0)const;
</pre>
<b></b>
<p><b>Effects:</b> Returns <code>std::distance(prefix().first,
(*this)[sub].first).</code></p>
<pre>
string_type str(int sub = 0)const;
</pre>
<b></b>
<p><b>Effects:</b> Returns <code>
string_type((*this)[sub]).</code></p>
<pre>
const_reference operator[](int n) const;
</pre>
<b></b>
<p><b>Effects:</b> Returns a reference to the <code>
sub_match</code> object representing the character sequence that
matched marked sub-expression <i>n</i>. If <code>n == 0</code> then
returns a reference to a <code>sub_match</code> object representing
the character sequence that matched the whole regular
expression.</p>
<pre>
const_reference prefix()const;
</pre>
<b></b>
<p><b>Effects:</b> Returns a reference to the <code>
sub_match</code> object representing the character sequence from
the start of the string being matched/searched, to the start of the
match found.</p>
<pre>
const_reference suffix()const;
</pre>
<b></b>
<p><b>Effects:</b> Returns a reference to the <code>
sub_match</code> object representing the character sequence from
the end of the match found to the end of the string being
matched/searched.</p>
<pre>
const_iterator begin()const;
</pre>
<b></b>
<p><b>Effects:</b> Returns a starting iterator that enumerates over
all the marked sub-expression matches stored in *this.</p>
<pre>
const_iterator end()const;
</pre>
<b></b>
<p><b>Effects:</b> Returns a terminating iterator that enumerates
over all the marked sub-expression matches stored in *this.</p>
<h4>match_results reformatting</h4>
<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);</PRE>
<B>
<P>
Requires: </B>The type OutputIterator conforms to the Output Iterator
requirements (24.1.2).</P><B>
<P>
Effects:</B> Copies the character sequence <I>[fmt.begin(), fmt.end())</I> to
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
the format used by ECMA-262, ECMAScript Language Specification, Chapter 15 part
5.4.11 String.prototype.replace.</P><B>
<P>
Returns:</B> <I>out</I>.</P><PRE>string_type format(const string_type&amp; fmt,
<A href="match_flag_type.html">match_flag_type</A> flags = format_default);</PRE>
<B>
<P>
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,
ECMAScript Language Specification, Chapter 15 part 5.4.11
String.prototype.replace.</P><PRE>allocator_type get_allocator()const;</PRE>
<B>
<P>
Effects:</B> Returns a copy of the Allocator that was passed to the object's
constructor.</P><PRE>void swap(match_results&amp; that);</PRE>
<B>
<P>
Effects:</B> Swaps the contents of the two sequences. </P><B>
<P>
Postcondition:</B> <CODE>*this</CODE> contains the sequence of matched
sub-expressions that were in <CODE>that</CODE>, <CODE>that</CODE> contains the
sequence of matched sub-expressions that were in <CODE>*this</CODE>. </P><B>
<P>
Complexity:</B> constant time.
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
<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 requirements (24.1.2).</p>
<b></b>
<p><b>Effects:</b> Copies the character sequence <i>[fmt.begin(),
fmt.end())</i> to 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 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>
string_type format(const string_type&amp; fmt,
<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, ECMAScript Language Specification,
Chapter 15 part 5.4.11 String.prototype.replace.</p>
<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>
void swap(match_results&amp; that);
</pre>
<b></b>
<p><b>Effects:</b> Swaps the contents of the two sequences.</p>
<b></b>
<p><b>Postcondition:</b> <code>*this</code> contains the sequence
of matched sub-expressions that were in <code>that</code>, <code>
that</code> contains the sequence of matched sub-expressions that
were in <code>*this</code>.</p>
<b></b>
<p><b>Complexity:</b> constant time.</p>
<p></p>
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
<p><i>&copy; Copyright <a href="mailto:jm@regex.fsnet.co.uk">John
Maddock</a>&nbsp;1998-
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
<p align="left"><i>Permission to use, copy, modify, distribute and
sell this software and its documentation for any purpose is hereby
granted without fee, provided that the above copyright notice
appear in all copies and that both that copyright notice and this
permission notice appear in supporting documentation. Dr John
Maddock makes no representations about the suitability of this
software for any purpose. It is provided "as is" without express or
implied warranty.</i></p>
</body>
</html>

View File

@ -170,7 +170,7 @@ void search(std::istream&amp; is)
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
@ -182,3 +182,4 @@ void search(std::istream&amp; is)
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

54
doc/performance.html Normal file
View File

@ -0,0 +1,54 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Performance</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">Performance</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>
<P>The performance of Boost.regex in both recursive and non-recursive modes should
be broadly comparable to other regular expression libraries: recursive mode is
slightly faster (especially where memory allocation requires thread
synchronisation), but not by much.&nbsp; The following pages compare
Boost.regex with various other regular expression libraries for the following
compilers:</P>
<P><A href="vc71-performance.html">Visual Studio.Net 2003 (recursive Boost.regex
implementation)</A>.</P>
<P><A href="gcc-performance.html">Gcc 3.2 (cygwin) (non-recursive Boost.regex
implementation).</A></P>
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -273,7 +273,7 @@
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
@ -285,3 +285,4 @@
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -69,7 +69,7 @@
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
@ -81,3 +81,4 @@
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -31,7 +31,7 @@
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
@ -43,3 +43,4 @@
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -1,55 +1,91 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: regbase</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">regbase</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>
<P>Use of the type <code>boost::regbase</code> is now deprecated, and the type does not form a
part of the <A href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1429.htm">
regular expression standardization proposal</A>.&nbsp; This type still
exists as a base class of <code>boost::basic_regex</code>, and you can still refer to
<code>boost::regbase::constant_name</code> in your code, however for maximum portability to
other std regex implementations you should instead use either:</P>
<PRE>boost::regex_constants::constant_name</PRE>
<P>or</P>
<PRE>boost::regex::constant_name</PRE>
<P>or</P>
<PRE>boost::wregex::constant_name</PRE>
<P>
<HR>
</P>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<title>Boost.Regex: regbase</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></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">regbase</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>
<br>
<br>
<hr>
<p>Use of the type <code>boost::regbase</code> is now deprecated,
and the type does not form a part of the <a href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1429.htm">
regular expression standardization proposal</a>.&nbsp; This type
still exists as a base class of <code>boost::basic_regex</code>,
and you can still refer to <code>
boost::regbase::constant_name</code> in your code, however for
maximum portability to other std regex implementations you should
instead use either:</p>
<pre>
boost::regex_constants::constant_name
</pre>
<p>or</p>
<pre>
boost::regex::constant_name
</pre>
<p>or</p>
<pre>
boost::wregex::constant_name
</pre>
<p></p>
<hr>
<br>
<br>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
<p><i>&copy; Copyright <a href="mailto:jm@regex.fsnet.co.uk">John
Maddock</a>&nbsp;1998-
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
<p align="left"><i>Permission to use, copy, modify, distribute and
sell this software and its documentation for any purpose is hereby
granted without fee, provided that the above copyright notice
appear in all copies and that both that copyright notice and this
permission notice appear in supporting documentation. Dr John
Maddock makes no representations about the suitability of this
software for any purpose. It is provided "as is" without express or
implied warranty.</i></p>
</body>
</html>

File diff suppressed because it is too large Load Diff

View File

@ -1,158 +1,213 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Algorithm regex_format (deprecated)</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">Algorithm regex_format (deprecated)</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>
<P>The algorithm regex_format is deprecated; new code should use
match_results::format instead.&nbsp; Existing code will continue to compile,
the following documentation is taken from the previous version of boost.regex
and will not be further updated:</P>
<H3>Algorithm regex_format</H3>
<H3></H3>
<PRE>#include &lt;<A href="../../boost/regex.hpp">boost/regex.hpp</A>&gt; </PRE>
<P>The algorithm regex_format takes the results of a match and creates a new
string based upon a <A href="format_syntax.html">format string</A>,
regex_format can be used for search and replace operations:
</P>
<PRE><B>template</B> &lt;<B>class</B> OutputIterator, <B>class</B> iterator, <B>class</B> Allocator, <B>class</B> charT&gt;
OutputIterator regex_format(OutputIterator out,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>const</B> match_results&lt;iterator, Allocator&gt;&amp; m,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>const</B> charT* fmt,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; match_flag_type flags = 0);
<B>
template</B> &lt;<B>class</B> OutputIterator, <B>class</B> iterator, <B>class</B> Allocator, <B>class</B> charT&gt;
OutputIterator regex_format(OutputIterator out,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>const</B> match_results&lt;iterator, Allocator&gt;&amp; m,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>const</B> std::basic_string&lt;charT&gt;&amp; fmt,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; match_flag_type flags = 0);</PRE>
<P>The library also defines the following convenience variation of regex_format,
which returns the result directly as a string, rather than outputting to an
iterator [note - this version may not be available, or may be available in a
more limited form, depending upon your compilers capabilities]:
</P>
<PRE><B>template</B> &lt;<B>class</B> iterator, <B>class</B> Allocator, <B>class</B> charT&gt;
std::basic_string&lt;charT&gt; regex_format
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (<B>const</B> match_results&lt;iterator, Allocator&gt;&amp; m,&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>const</B> charT* fmt,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; match_flag_type flags = 0);
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<title>Boost.Regex: Algorithm regex_format (deprecated)</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></p>
<B>template</B> &lt;<B>class</B> iterator, <B>class</B> Allocator, <B>class</B> charT&gt;
<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">Algorithm regex_format (deprecated)</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>
<br>
<br>
<hr>
<p>The algorithm regex_format is deprecated; new code should use
match_results::format instead.&nbsp; Existing code will continue to
compile, the following documentation is taken from the previous
version of boost.regex and will not be further updated:</p>
<h3>Algorithm regex_format</h3>
<pre>
#include &lt;<a href="../../boost/regex.hpp">boost/regex.hpp</a>&gt;
</pre>
<p>The algorithm regex_format takes the results of a match and
creates a new string based upon a <a href="format_syntax.html">
format string</a>, regex_format can be used for search and replace
operations:</p>
<pre>
<b>template</b> &lt;<b>class</b> OutputIterator, <b>class</b> iterator, <b>class</b> Allocator, <b>class</b> charT&gt;
OutputIterator regex_format(OutputIterator out,
<b>const</b> match_results&lt;iterator, Allocator&gt;&amp; m,
<b>const</b> charT* fmt,
match_flag_type flags = 0);
<b>template</b> &lt;<b>class</b> OutputIterator, <b>class</b> iterator, <b>class</b> Allocator, <b>class</b> charT&gt;
OutputIterator regex_format(OutputIterator out,
<b>const</b> match_results&lt;iterator, Allocator&gt;&amp; m,
<b>const</b> std::basic_string&lt;charT&gt;&amp; fmt,
match_flag_type flags = 0);
</pre>
<p>The library also defines the following convenience variation of
regex_format, which returns the result directly as a string, rather
than outputting to an iterator [note - this version may not be
available, or may be available in a more limited form, depending
upon your compilers capabilities]:</p>
<pre>
<b>template</b> &lt;<b>class</b> iterator, <b>class</b> Allocator, <b>class</b> charT&gt;
std::basic_string&lt;charT&gt; regex_format
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (<B>const</B> match_results&lt;iterator, Allocator&gt;&amp; m,&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>const</B> std::basic_string&lt;charT&gt;&amp; fmt,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; match_flag_type flags = 0);</PRE>
<P>Parameters to the main version of the function are passed as follows:
</P>
<P>
<TABLE id="Table2" cellSpacing="0" cellPadding="7" width="100%" border="0">
<TR>
<TD vAlign="top" width="9%">&nbsp;</TD>
<TD vAlign="top" width="39%">OutputIterator out</TD>
<TD vAlign="top" width="44%">An output iterator type, the output string is sent to
this iterator. Typically this would be a std::ostream_iterator.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="9%">&nbsp;</TD>
<TD vAlign="top" width="39%"><B>const</B> match_results&lt;iterator,
Allocator&gt;&amp; m</TD>
<TD vAlign="top" width="44%">An instance of match_results&lt;&gt; obtained from
one of the matching algorithms above, and denoting what matched.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="9%">&nbsp;</TD>
<TD vAlign="top" width="39%"><B>const</B> charT* fmt</TD>
<TD vAlign="top" width="44%">A format string that determines how the match is
transformed into the new string.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="9%">&nbsp;</TD>
<TD vAlign="top" width="39%"><B>unsigned</B> flags</TD>
<TD vAlign="top" width="44%">Optional flags which describe how the format string
is to be interpreted.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
</TABLE>
</P>
<P><A name="format_flags"></A>Format flags are defined as follows:
</P>
<P>
<TABLE id="Table3" cellSpacing="0" cellPadding="7" width="100%" border="0">
<TR>
<TD vAlign="top" width="9%">&nbsp;</TD>
<TD vAlign="top" width="39%">format_all</TD>
<TD vAlign="top" width="43%">Enables all syntax options (perl-like plus
extentions).</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="9%">&nbsp;</TD>
<TD vAlign="top" width="39%">format_sed</TD>
<TD vAlign="top" width="43%">Allows only a sed-like syntax.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="9%">&nbsp;</TD>
<TD vAlign="top" width="39%">format_perl</TD>
<TD vAlign="top" width="43%">Allows only a perl-like syntax.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="9%">&nbsp;</TD>
<TD vAlign="top" width="39%">format_no_copy</TD>
<TD vAlign="top" width="43%">Disables copying of unmatched sections to the output
string during <A href="regex_merge.html">regex_merge</A> operations.</TD>
<TD vAlign="top" width="9%">&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD>format_first_only</TD>
<TD>When this flag is set only the first occurance will be replaced (applies to
regex_merge only).</TD>
<TD>&nbsp;</TD>
</TR>
</TABLE>
</P>
<P>The format string syntax (and available options) is described more fully under <A href="format_syntax.html">
format strings</A>
.
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
(<b>const</b> match_results&lt;iterator, Allocator&gt;&amp; m,
<b>const</b> charT* fmt,
match_flag_type flags = 0);
<b>template</b> &lt;<b>class</b> iterator, <b>class</b> Allocator, <b>class</b> charT&gt;
std::basic_string&lt;charT&gt; regex_format
(<b>const</b> match_results&lt;iterator, Allocator&gt;&amp; m,
<b>const</b> std::basic_string&lt;charT&gt;&amp; fmt,
match_flag_type flags = 0);
</pre>
<p>Parameters to the main version of the function are passed as
follows:</p>
<p></p>
<table id="Table2" cellspacing="0" cellpadding="7" width="100%"
border="0">
<tr>
<td valign="top" width="9%">&nbsp;</td>
<td valign="top" width="39%">OutputIterator out</td>
<td valign="top" width="44%">An output iterator type, the output
string is sent to this iterator. Typically this would be a
std::ostream_iterator.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="9%">&nbsp;</td>
<td valign="top" width="39%"><b>const</b>
match_results&lt;iterator, Allocator&gt;&amp; m</td>
<td valign="top" width="44%">An instance of match_results&lt;&gt;
obtained from one of the matching algorithms above, and denoting
what matched.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="9%">&nbsp;</td>
<td valign="top" width="39%"><b>const</b> charT* fmt</td>
<td valign="top" width="44%">A format string that determines how
the match is transformed into the new string.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="9%">&nbsp;</td>
<td valign="top" width="39%"><b>unsigned</b> flags</td>
<td valign="top" width="44%">Optional flags which describe how the
format string is to be interpreted.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
</table>
<br>
<br>
<p><a name="format_flags"></a>Format flags are defined as
follows:</p>
<p></p>
<table id="Table3" cellspacing="0" cellpadding="7" width="100%"
border="0">
<tr>
<td valign="top" width="9%">&nbsp;</td>
<td valign="top" width="39%">format_all</td>
<td valign="top" width="43%">Enables all syntax options (perl-like
plus extentions).</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="9%">&nbsp;</td>
<td valign="top" width="39%">format_sed</td>
<td valign="top" width="43%">Allows only a sed-like syntax.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="9%">&nbsp;</td>
<td valign="top" width="39%">format_perl</td>
<td valign="top" width="43%">Allows only a perl-like syntax.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="9%">&nbsp;</td>
<td valign="top" width="39%">format_no_copy</td>
<td valign="top" width="43%">Disables copying of unmatched sections
to the output string during <a href="regex_merge.html">
regex_merge</a> operations.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>format_first_only</td>
<td>When this flag is set only the first occurance will be replaced
(applies to regex_merge only).</td>
<td>&nbsp;</td>
</tr>
</table>
<br>
<br>
<p>The format string syntax (and available options) is described
more fully under <a href="format_syntax.html">format strings</a>
.</p>
<p></p>
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
<p><i>&copy; Copyright <a href="mailto:jm@regex.fsnet.co.uk">John
Maddock</a>&nbsp;1998-
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
<p align="left"><i>Permission to use, copy, modify, distribute and
sell this software and its documentation for any purpose is hereby
granted without fee, provided that the above copyright notice
appear in all copies and that both that copyright notice and this
permission notice appear in supporting documentation. Dr John
Maddock makes no representations about the suitability of this
software for any purpose. It is provided "as is" without express or
implied warranty.</i></p>
</body>
</html>

View File

@ -2,140 +2,148 @@
<html>
<head>
<title>Boost.Regex: Algorithm regex_grep (deprecated)</title>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<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">Algorithm regex_grep (deprecated)</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>
<P>The algorithm regex_grep is deprecated in favor of <A href="regex_iterator.html">regex_iterator</A>
which provides a more convenient and standard library friendly interface.</P>
<P>The following documentation is taken unchanged from the previous boost release,
and will not be updated in future.</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">Algorithm regex_grep (deprecated)</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>
<br>
<br>
<hr>
<PRE>#include &lt;<A href="../../boost/regex.hpp">boost/regex.hpp</A>&gt; </PRE>
<P>regex_grep allows you to search through a bidirectional-iterator range and
<p>The algorithm regex_grep is deprecated in favor of <a href="regex_iterator.html">regex_iterator</a>
which provides a more convenient and standard library friendly interface.</p>
<p>The following documentation is taken unchanged from the previous boost release,
and will not be updated in future.</p>
<hr>
<pre>
#include &lt;<a href="../../boost/regex.hpp">boost/regex.hpp</a>&gt;
</pre>
<p>regex_grep allows you to search through a bidirectional-iterator range and
locate all the (non-overlapping) matches with a given regular expression. The
function is declared as:
</P>
<PRE><B>template</B> &lt;<B>class</B> Predicate, <B>class</B> iterator, <B>class</B> charT, <B>class</B> traits, <B>class</B> Allocator&gt;
<B>unsigned</B> <B>int</B> regex_grep(Predicate foo,
function is declared as:</p>
<pre>
<b>template</b> &lt;<b>class</b> Predicate, <b>class</b> iterator, <b>class</b> charT, <b>class</b> traits, <b>class</b> Allocator&gt;
<b>unsigned</b> <b>int</b> regex_grep(Predicate foo,
iterator first,
iterator last,
<B>const</B> basic_regex&lt;charT, traits, Allocator&gt;&amp; e,
<B>unsigned</B> flags = match_default)</PRE>
<P>The library also defines the following convenience versions, which take either
<b>const</b> basic_regex&lt;charT, traits, Allocator&gt;&amp; e,
<b>unsigned</b> flags = match_default)
</pre>
<p>The library also defines the following convenience versions, which take either
a const charT*, or a const std::basic_string&lt;&gt;&amp; in place of a pair of
iterators [note - these versions may not be available, or may be available in a
more limited form, depending upon your compilers capabilities]:
</P>
<PRE><B>template</B> &lt;<B>class</B> Predicate, <B>class</B> charT, <B>class</B> Allocator, <B>class</B> traits&gt;
<B>unsigned</B> <B>int</B> regex_grep(Predicate foo,&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>const</B> charT* str,&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>const</B> basic_regex&lt;charT, traits, Allocator&gt;&amp; e,&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>unsigned</B> flags = match_default);
more limited form, depending upon your compilers capabilities]:</p>
<pre>
<b>template</b> &lt;<b>class</b> Predicate, <b>class</b> charT, <b>class</b> Allocator, <b>class</b> traits&gt;
<b>unsigned</b> <b>int</b> regex_grep(Predicate foo,
<b>const</b> charT* str,
<b>const</b> basic_regex&lt;charT, traits, Allocator&gt;&amp; e,
<b>unsigned</b> flags = match_default);
<B>template</B> &lt;<B>class</B> Predicate, <B>class</B> ST, <B>class</B> SA, <B>class</B> Allocator, <B>class</B> charT, <B>class</B> traits&gt;
<B>unsigned</B> <B>int</B> regex_grep(Predicate foo,&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>const</B> std::basic_string&lt;charT, ST, SA&gt;&amp; s,&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>const</B> basic_regex&lt;charT, traits, Allocator&gt;&amp; e,&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>unsigned</B> flags = match_default);</PRE>
<P>The parameters for the primary version of regex_grep have the following
meanings:&nbsp;
</P>
<P>
<TABLE id="Table2" cellSpacing="0" cellPadding="7" width="624" border="0">
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="50%">foo</TD>
<TD vAlign="top" width="50%">A predicate function object or function pointer, see
below for more information.</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">first</TD>
<TD vAlign="top" width="50%">The start of the range to search.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">last</TD>
<TD vAlign="top" width="50%">The end of the range to search.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">e</TD>
<TD vAlign="top" width="50%">The regular expression to search for.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">flags</TD>
<TD vAlign="top" width="50%">The flags that determine how matching is carried out,
one of the <A href="#match_type">match_flags</A> enumerators.</TD>
<TD>&nbsp;</TD>
</TR>
</TABLE>
</P>
<P>The algorithm finds all of the non-overlapping matches of the expression e, for
each match it fills a <A href="#reg_match">match_results</A>&lt;iterator,
<b>template</b> &lt;<b>class</b> Predicate, <b>class</b> ST, <b>class</b> SA, <b>class</b> Allocator, <b>class</b> charT, <b>class</b> traits&gt;
<b>unsigned</b> <b>int</b> regex_grep(Predicate foo,
<b>const</b> std::basic_string&lt;charT, ST, SA&gt;&amp; s,
<b>const</b> basic_regex&lt;charT, traits, Allocator&gt;&amp; e,
<b>unsigned</b> flags = match_default);
</pre>
<p>The parameters for the primary version of regex_grep have the following
meanings:&nbsp;</p>
<p></p>
<table id="Table2" cellspacing="0" cellpadding="7" width="624" border="0">
<tr>
<td width="5%">&nbsp;</td>
<td valign="top" width="50%">foo</td>
<td valign="top" width="50%">A predicate function object or function pointer, see
below for more information.</td>
<td width="5%">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td valign="top" width="50%">first</td>
<td valign="top" width="50%">The start of the range to search.</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td valign="top" width="50%">last</td>
<td valign="top" width="50%">The end of the range to search.</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td valign="top" width="50%">e</td>
<td valign="top" width="50%">The regular expression to search for.</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td valign="top" width="50%">flags</td>
<td valign="top" width="50%">The flags that determine how matching is carried out,
one of the <a href="#match_type">match_flags</a> enumerators.</td>
<td>&nbsp;</td>
</tr>
</table>
<br>
<br>
<p>The algorithm finds all of the non-overlapping matches of the expression e, for
each match it fills a <a href="#reg_match">match_results</a>&lt;iterator,
Allocator&gt; structure, which contains information on what matched, and calls
the predicate foo, passing the match_results&lt;iterator, Allocator&gt; as a
single argument. If the predicate returns true, then the grep operation
continues, otherwise it terminates without searching for further matches. The
function returns the number of matches found.</P>
<P>The general form of the predicate is:
</P>
<PRE><B>struct</B> grep_predicate
function returns the number of matches found.</p>
<p>The general form of the predicate is:</p>
<pre>
<b>struct</b> grep_predicate
{
<B>&nbsp;&nbsp; bool</B> <B>operator</B>()(<B>const</B> match_results&lt;iterator_type, typename expression_type::alloc_type::template rebind&lt;sub_match&lt;BidirectionalIterator&gt; &gt;::other&gt;&amp; m);
};</PRE>
<P>Note that in almost every case the allocator parameter can be omitted, when
specifying the <A href="match_results.html">match_results</A> type,
<b> bool</b> <b>operator</b>()(<b>const</b> match_results&lt;iterator_type, typename expression_type::alloc_type::template rebind&lt;sub_match&lt;BidirectionalIterator&gt; &gt;::other&gt;&amp; m);
};
</pre>
<p>Note that in almost every case the allocator parameter can be omitted, when
specifying the <a href="match_results.html">match_results</a> type,
alternatively one of the typedefs cmatch, wcmatch, smatch or wsmatch can be
used.
</P>
<P>For example the regular expression "a*b" would find one match in the string
"aaaaab" and two in the string "aaabb".
</P>
<P>Remember this algorithm can be used for a lot more than implementing a version
used.</p>
<p>For example the regular expression "a*b" would find one match in the string
"aaaaab" and two in the string "aaabb".</p>
<p>Remember this algorithm can be used for a lot more than implementing a version
of grep, the predicate can be and do anything that you want, grep utilities
would output the results to the screen, another program could index a file
based on a regular expression and store a set of bookmarks in a list, or a text
file conversion utility would output to file. The results of one regex_grep can
even be chained into another regex_grep to create recursive parsers.
</P>
<P><A href="../example/snippets/regex_grep_example_1.cpp">Example</A>: convert the
example from <I>regex_search</I> to use <I>regex_grep</I> instead:
</P>
<PRE><FONT color=#008000>#include &lt;string&gt;
even be chained into another regex_grep to create recursive parsers.</p>
<P>The algorithm may throw&nbsp;<CODE>std::runtime_error</CODE> if the complexity
of matching the expression against an N character string begins to exceed O(N<SUP>2</SUP>),
or if the program runs out of stack space while matching the expression (if
Boost.regex is <A href="configuration.html">configured</A> in recursive mode),
or if the matcher exhausts it's permitted memory allocation (if Boost.regex is <A href="configuration.html">
configured</A> in non-recursive mode).</P>
<p><a href="../example/snippets/regex_grep_example_1.cpp"> Example</a>: convert
the example from <i>regex_search</i> to use <i>regex_grep</i> instead:</p>
<pre>
<font color="#008000">#include &lt;string&gt;
#include &lt;map&gt;
#include &lt;boost/regex.hpp&gt;
</FONT><FONT color=#000080><I>// IndexClasses:
</font><font color="#000080"><i>// IndexClasses:
// takes the contents of a file in the form of a string
// and searches for all the C++ class definitions, storing
// their locations in a map of strings/int's
</I></FONT><B>
typedef</B> std::map&lt;std::string, <B>int</B>, std::less&lt;std::string&gt; &gt; map_type;
</i></font><b>typedef</b> std::map&lt;std::string, <b>int</b>, std::less&lt;std::string&gt; &gt; map_type;
const char* re =
// possibly leading whitespace:
@ -160,45 +168,44 @@ const char* re =
"(\\{|:[^;\\{()]*\\{)";
boost::regex expression(re);
<B>
class</B> IndexClassesPred
<b>class</b> IndexClassesPred
{
&nbsp;&nbsp; map_type&amp; m;
&nbsp;&nbsp; std::string::const_iterator base;
<B>public</B>:
&nbsp;&nbsp; IndexClassesPred(map_type&amp; a, std::string::const_iterator b) : m(a), base(b) {}
&nbsp;&nbsp; <B>bool</B> <B>operator</B>()(<B>const</B> smatch&amp; what)
&nbsp;&nbsp; {
<FONT color=#000080>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <I>// what[0] contains the whole string
</I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <I>// what[5] contains the class name.
</I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <I>// what[6] contains the template specialisation if any.
</I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <I>// add class name and position to map:
</I></FONT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m[std::string(what[5].first, what[5].second) + std::string(what[6].first, what[6].second)] =&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; what[5].first - base;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>return</B> <B>true</B>;
&nbsp;&nbsp; }
map_type&amp; m;
std::string::const_iterator base;
<b>public</b>:
IndexClassesPred(map_type&amp; a, std::string::const_iterator b) : m(a), base(b) {}
<b>bool</b> <b>operator</b>()(<b>const</b> smatch&amp; what)
{
<font color=
#000080> <i>// what[0] contains the whole string
</i> <i>// what[5] contains the class name.
</i> <i>// what[6] contains the template specialisation if any.
</i> <i>// add class name and position to map:
</i></font> m[std::string(what[5].first, what[5].second) + std::string(what[6].first, what[6].second)] =
what[5].first - base;
<b>return</b> <b>true</b>;
}
};
<B>
void</B> IndexClasses(map_type&amp; m, <B>const</B> std::string&amp; file)
<b>void</b> IndexClasses(map_type&amp; m, <b>const</b> std::string&amp; file)
{
&nbsp;&nbsp; std::string::const_iterator start, end;
&nbsp;&nbsp; start = file.begin();
&nbsp;&nbsp; end = file.end();
&nbsp;&nbsp; regex_grep(IndexClassesPred(m, start), start, end, expression);
} </PRE>
<P><A href="../example/snippets/regex_grep_example_2.cpp">Example</A>: Use
regex_grep to call a global callback function:
</P>
<PRE><FONT color=#008000>#include &lt;string&gt;
std::string::const_iterator start, end;
start = file.begin();
end = file.end();
regex_grep(IndexClassesPred(m, start), start, end, expression);
}
</pre>
<p><a href="../example/snippets/regex_grep_example_2.cpp"> Example</a>: Use
regex_grep to call a global callback function:</p>
<pre>
<font color="#008000">#include &lt;string&gt;
#include &lt;map&gt;
#include &lt;boost/regex.hpp&gt;
</FONT><FONT color=#000080><I>// purpose:
</font><font color="#000080"><i>// purpose:
// takes the contents of a file in the form of a string
// and searches for all the C++ class definitions, storing
// their locations in a map of strings/int's
</I></FONT><B>
typedef</B> std::map&lt;std::string, <B>int</B>, std::less&lt;std::string&gt; &gt; map_type;
</i></font><b>typedef</b> std::map&lt;std::string, <b>int</b>, std::less&lt;std::string&gt; &gt; map_type;
const char* re =
// possibly leading whitespace:
@ -226,152 +233,154 @@ boost::regex expression(re);
map_type class_index;
std::string::const_iterator base;
<B>bool</B> grep_callback(<B>const</B> boost::smatch&amp; what)
<b>bool</b> grep_callback(<b>const</b> boost::smatch&amp; what)
{
<FONT color=#000080>&nbsp;&nbsp; <I>// what[0] contains the whole string
</I>&nbsp;&nbsp; <I>// what[5] contains the class name.
</I>&nbsp;&nbsp; <I>// what[6] contains the template specialisation if any.
</I>&nbsp;&nbsp; <I>// add class name and position to map:
</I></FONT>&nbsp;&nbsp; class_index[std::string(what[5].first, what[5].second) + std::string(what[6].first, what[6].second)] =&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; what[5].first - base;
&nbsp;&nbsp; <B>return</B> <B>true</B>;
<font color="#000080"> <i>// what[0] contains the whole string
</i> <i>// what[5] contains the class name.
</i> <i>// what[6] contains the template specialisation if any.
</i> <i>// add class name and position to map:
</i></font> class_index[std::string(what[5].first, what[5].second) + std::string(what[6].first, what[6].second)] =
what[5].first - base;
<b>return</b> <b>true</b>;
}
<B>
void</B> IndexClasses(<B>const</B> std::string&amp; file)
<b>void</b> IndexClasses(<b>const</b> std::string&amp; file)
{
&nbsp;&nbsp; std::string::const_iterator start, end;
&nbsp;&nbsp; start = file.begin();
&nbsp;&nbsp; end = file.end();
&nbsp;&nbsp; base = start;
&nbsp;&nbsp; regex_grep(grep_callback, start, end, expression, match_default);
std::string::const_iterator start, end;
start = file.begin();
end = file.end();
base = start;
regex_grep(grep_callback, start, end, expression, match_default);
}
&nbsp; </PRE>
<P><A href="../example/snippets/regex_grep_example_3.cpp">Example</A>: use
regex_grep to call a class member function, use the standard library adapters <I>std::mem_fun</I>
and <I>std::bind1st</I> to convert the member function into a predicate:
</P>
<PRE><FONT color=#008000>#include &lt;string&gt;
</pre>
<p><a href="../example/snippets/regex_grep_example_3.cpp"> Example</a>: use
regex_grep to call a class member function, use the standard library adapters <i>std::mem_fun</i>
and <i>std::bind1st</i> to convert the member function into a predicate:</p>
<pre>
<font color="#008000">#include &lt;string&gt;
#include &lt;map&gt;
#include &lt;boost/regex.hpp&gt;
#include &lt;functional&gt;
</FONT><FONT color=#000080><I>
// purpose:
</font><font color="#000080"><i>// purpose:
// takes the contents of a file in the form of a string
// and searches for all the C++ class definitions, storing
// their locations in a map of strings/int's
</I></FONT><B>typedef</B> std::map&lt;std::string, <B>int</B>, std::less&lt;std::string&gt; &gt; map_type;
<B>
class</B> class_index
</i></font><b>typedef</b> std::map&lt;std::string, <b>int</b>, std::less&lt;std::string&gt; &gt; map_type;
<b>class</b> class_index
{
&nbsp;&nbsp; boost::regex expression;
&nbsp;&nbsp; map_type index;
&nbsp;&nbsp; std::string::const_iterator base;
&nbsp;&nbsp; <B>bool</B> grep_callback(boost::smatch what);
<B>public</B>:
<B>&nbsp;&nbsp; void</B> IndexClasses(<B>const</B> std::string&amp; file);
&nbsp;&nbsp; class_index()
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : index(),
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; expression(<FONT color=#000080>"^(template[[:space:]]*&lt;[^;:{]+&gt;[[:space:]]*)?"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "(class|struct)[[:space:]]*(\\&lt;\\w+\\&gt;([[:blank:]]*\\([^)]*\\))?"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "[[:space:]]*)*(\\&lt;\\w*\\&gt;)[[:space:]]*(&lt;[^;:{]+&gt;[[:space:]]*)?"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "(\\{|:[^;\\{()]*\\{)"
</FONT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ){}
boost::regex expression;
map_type index;
std::string::const_iterator base;
<b>bool</b> grep_callback(boost::smatch what);
<b>public</b>:
<b> void</b> IndexClasses(<b>const</b> std::string&amp; file);
class_index()
: index(),
expression(<font color=
#000080>"^(template[[:space:]]*&lt;[^;:{]+&gt;[[:space:]]*)?"
"(class|struct)[[:space:]]*(\\&lt;\\w+\\&gt;([[:blank:]]*\\([^)]*\\))?"
"[[:space:]]*)*(\\&lt;\\w*\\&gt;)[[:space:]]*(&lt;[^;:{]+&gt;[[:space:]]*)?"
"(\\{|:[^;\\{()]*\\{)"
</font> ){}
};
<B>
bool</B> class_index::grep_callback(boost::smatch what)
<b>bool</b> class_index::grep_callback(boost::smatch what)
{
<FONT color=#000080>&nbsp;&nbsp; <I>// what[0] contains the whole string
</I>&nbsp;&nbsp; <I>// what[5] contains the class name.
</I>&nbsp;&nbsp; <I>// what[6] contains the template specialisation if any.
</I>&nbsp;&nbsp; <I>// add class name and position to map:
</I></FONT>&nbsp;&nbsp; index[std::string(what[5].first, what[5].second) + std::string(what[6].first, what[6].second)] =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; what[5].first - base;
&nbsp;&nbsp; <B>return</B> <B>true</B>;
<font color="#000080"> <i>// what[0] contains the whole string
</i> <i>// what[5] contains the class name.
</i> <i>// what[6] contains the template specialisation if any.
</i> <i>// add class name and position to map:
</i></font> index[std::string(what[5].first, what[5].second) + std::string(what[6].first, what[6].second)] =
what[5].first - base;
<b>return</b> <b>true</b>;
}
<B>void</B> class_index::IndexClasses(<B>const</B> std::string&amp; file)
<b>void</b> class_index::IndexClasses(<b>const</b> std::string&amp; file)
{
&nbsp;&nbsp; std::string::const_iterator start, end;
&nbsp;&nbsp; start = file.begin();
&nbsp;&nbsp; end = file.end();
&nbsp;&nbsp; base = start;
&nbsp;&nbsp; regex_grep(std::bind1st(std::mem_fun(&amp;class_index::grep_callback), <B>this</B>),
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; start,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; expression);
std::string::const_iterator start, end;
start = file.begin();
end = file.end();
base = start;
regex_grep(std::bind1st(std::mem_fun(&amp;class_index::grep_callback), <b>this</b>),
start,
end,
expression);
}
&nbsp; </PRE>
<P><A href="../example/snippets/regex_grep_example_4.cpp">Finally</A>, C++ Builder
users can use C++ Builder's closure type as a callback argument:
</P>
<PRE><FONT color=#008000>#include &lt;string&gt;
</pre>
<p><a href="../example/snippets/regex_grep_example_4.cpp"> Finally</a>, C++
Builder users can use C++ Builder's closure type as a callback argument:</p>
<pre>
<font color="#008000">#include &lt;string&gt;
#include &lt;map&gt;
#include &lt;boost/regex.hpp&gt;
#include &lt;functional&gt;
</FONT><FONT color=#000080><I>
// purpose:
</font><font color="#000080"><i>// purpose:
// takes the contents of a file in the form of a string
// and searches for all the C++ class definitions, storing
// their locations in a map of strings/int's
</I></FONT><B>typedef</B> std::map&lt;std::string, <B>int</B>, std::less&lt;std::string&gt; &gt; map_type;
<B>class</B> class_index
</i></font><b>typedef</b> std::map&lt;std::string, <b>int</b>, std::less&lt;std::string&gt; &gt; map_type;
<b>class</b> class_index
{
&nbsp;&nbsp; boost::regex expression;
&nbsp;&nbsp; map_type index;
&nbsp;&nbsp; std::string::const_iterator base;
&nbsp;&nbsp; <B>typedef</B> boost::smatch arg_type;
&nbsp;&nbsp; <B>bool</B> grep_callback(<B>const</B> arg_type&amp; what);
<B>public</B>:
&nbsp;&nbsp; <B>typedef</B> <B>bool</B> (<B>__closure</B>* grep_callback_type)(<B>const</B> arg_type&amp;);
&nbsp;&nbsp; <B>void</B> IndexClasses(<B>const</B> std::string&amp; file);
&nbsp;&nbsp; class_index()
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : index(),
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; expression(<FONT color=#000080>"^(template[[:space:]]*&lt;[^;:{]+&gt;[[:space:]]*)?"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "(class|struct)[[:space:]]*(\\&lt;\\w+\\&gt;([[:blank:]]*\\([^)]*\\))?"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "[[:space:]]*)*(\\&lt;\\w*\\&gt;)[[:space:]]*(&lt;[^;:{]+&gt;[[:space:]]*)?"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "(\\{|:[^;\\{()]*\\{)"
</FONT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ){}
boost::regex expression;
map_type index;
std::string::const_iterator base;
<b>typedef</b> boost::smatch arg_type;
<b>bool</b> grep_callback(<b>const</b> arg_type&amp; what);
<b>public</b>:
<b>typedef</b> <b>bool</b> (<b>__closure</b>* grep_callback_type)(<b>const</b> arg_type&amp;);
<b>void</b> IndexClasses(<b>const</b> std::string&amp; file);
class_index()
: index(),
expression(<font color=
#000080>"^(template[[:space:]]*&lt;[^;:{]+&gt;[[:space:]]*)?"
"(class|struct)[[:space:]]*(\\&lt;\\w+\\&gt;([[:blank:]]*\\([^)]*\\))?"
"[[:space:]]*)*(\\&lt;\\w*\\&gt;)[[:space:]]*(&lt;[^;:{]+&gt;[[:space:]]*)?"
"(\\{|:[^;\\{()]*\\{)"
</font> ){}
};
<B>bool</B> class_index::grep_callback(<B>const</B> arg_type&amp; what)
<b>bool</b> class_index::grep_callback(<b>const</b> arg_type&amp; what)
{
<FONT color=#000080>&nbsp;&nbsp; <I>// what[0] contains the whole string </I>&nbsp;&nbsp;
<I>// what[5] contains the class name. </I>&nbsp;&nbsp;
<I>// what[6] contains the template specialisation if any. </I>&nbsp;&nbsp;
<I>// add class name and position to map: </I></FONT>&nbsp;&nbsp;
<font color=
#000080> <i>// what[0] contains the whole string</i>
<i>// what[5] contains the class name.</i>
<i>// what[6] contains the template specialisation if any.</i>
<i>// add class name and position to map:</i></font>
index[std::string(what[5].first, what[5].second) + std::string(what[6].first, what[6].second)] =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; what[5].first - base;
&nbsp;&nbsp; <B>return</B> <B>true</B>;
what[5].first - base;
<b>return</b> <b>true</b>;
}
<B>void</B> class_index::IndexClasses(<B>const</B> std::string&amp; file)
<b>void</b> class_index::IndexClasses(<b>const</b> std::string&amp; file)
{
&nbsp;&nbsp; std::string::const_iterator start, end;
&nbsp;&nbsp; start = file.begin();
&nbsp;&nbsp; end = file.end();
&nbsp;&nbsp; base = start;
&nbsp;&nbsp; class_index::grep_callback_type cl = &amp;(<B>this</B>-&gt;grep_callback);
&nbsp;&nbsp; regex_grep(cl,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; start,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; expression);
} </PRE>
<P>
<HR>
<P></P>
std::string::const_iterator start, end;
start = file.begin();
end = file.end();
base = start;
class_index::grep_callback_type cl = &amp;(<b>this</b>-&gt;grep_callback);
regex_grep(cl,
start,
end,
expression);
}
</pre>
<p></p>
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
<p><i><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
<p align="left"><i>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
for any purpose. It is provided "as is" without express or implied warranty.</i></p>
</body>
</html>

View File

@ -2,35 +2,39 @@
<html>
<head>
<title>Boost.Regex: regex_iterator</title>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<LINK href="../../../boost.css" type="text/css" rel="stylesheet"></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" 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">regex_iterator</H2>
</TD>
<td width="50">
<h3><A href="index.html"><IMG height="45" alt="Boost.Regex Index" src="uarrow.gif" width="43" border="0"></A></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<H3>Contents</H3>
<p></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" 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">regex_iterator</h2>
</td>
<td width="50">
<h3><a href="index.html"><img height="45" alt="Boost.Regex Index" src="uarrow.gif" width="43" border="0"></a></h3>
</td>
</tr>
</table>
<br>
<br>
<hr>
<h3>Contents</h3>
<dl class="index">
<dt><A href="#synopsis">Synopsis</A> <dt><a href="#description">Description</a> <dt><A href="#examples">
Examples</A></dt></dl>
<H3><A name="synopsis"></A>Synopsis</H3>
<P>The iterator type regex_iterator will enumerate all of the regular expression
<dt><a href="#synopsis">Synopsis</a> <dt><a href="#description">Description</a> <dt><a href="#examples">
Examples</a></dt>
</dl>
<h3><a name="synopsis"></a>Synopsis</h3>
<p>The iterator type regex_iterator will enumerate all of the regular expression
matches found in some sequence: dereferencing a regex_iterator yields a
reference to a&nbsp;<A href="match_results.html">match_results</A> object.</P>
<PRE>
reference to a&nbsp;<a href="match_results.html">match_results</a> object.</p>
<pre>
template &lt;class BidirectionalIterator,
class charT = iterator_traits&lt;BidirectionalIterator&gt;::value_type,
class traits = regex_traits&lt;charT&gt;,
@ -59,310 +63,365 @@ public:
regex_iterator operator++(int);
};
</PRE>
<H3><A name="description"></A>Description</H3>
<P>A regex_iterator is constructed from a pair of iterators, and enumerates all
occurrences of a regular expression within that iterator range.</P>
<PRE>regex_iterator();</PRE>
<B>
<P>
Effects:</B> constructs an end of sequence regex_iterator.</P><PRE>regex_iterator(BidirectionalIterator a, BidirectionalIterator b,
</pre>
<h3><a name="description"></a>Description</h3>
<p>A regex_iterator is constructed from a pair of iterators, and enumerates all
occurrences of a regular expression within that iterator range.</p>
<pre>
regex_iterator();
</pre>
<b></b>
<p><b>Effects:</b> constructs an end of sequence regex_iterator.</p>
<pre>
regex_iterator(BidirectionalIterator a, BidirectionalIterator b,
const regex_type&amp; re,
match_flag_type m = match_default);</PRE>
<B>
<P>
Effects: </B>constructs a regex_iterator that will enumerate all occurrences
of the expression <EM>re</EM>, within the sequence <EM>[a,b)</EM>, and found
using match flags <EM>m</EM>.&nbsp; The object <EM>re </EM>must exist for the
lifetime of the regex_iterator.</P><PRE>regex_iterator(const regex_iterator&amp; that);</PRE>
<B>
<P>
Effects: </B>constructs a copy of <CODE>that</CODE>.</P><B>
<P>
Postconditions:</B> <CODE>*this == that</CODE>.</P><PRE>regex_iterator&amp; operator=(const regex_iterator&amp;);</PRE>
<B>
<P>
Effects: </B>sets&nbsp;<CODE>*this</CODE> equal to those in <CODE>that</CODE>.</P><B>
<P>
Postconditions:</B> <CODE>*this == that</CODE>.</P><PRE>bool operator==(const regex_iterator&amp; that);</PRE>
<B>
<P>
Effects: </B>returns true if *this is equal to that.</P><PRE>bool operator!=(const regex_iterator&amp;);</PRE>
<B>
<P>
Effects: </B>returns <CODE>!(*this == that)</CODE>.</P>
<H5>RE.8.1.1 regex_iterator dereference</H5>
<PRE>const value_type&amp; operator*();</PRE>
<P>
<B>Effects:</B> dereferencing a regex_iterator object <EM>it</EM> yields a
const reference to a <A href="match_results.html">match_results</A> object,
whose members are set as follows:</P>
<P>
<TABLE id="Table2" cellSpacing="1" cellPadding="7" width="624" border="1">
<TBODY>
<TR>
<TD vAlign="top" width="50%"><B>
<P>
Element</B>
</P>
</TD>
<TD vAlign="top" width="50%"><B>
<P>
Value</B> </P></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>(*it).size()</P>
</TD>
<TD vAlign="top" width="50%">
<P>re.mark_count()</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>(*it).empty()</P>
</TD>
<TD vAlign="top" width="50%">
<P>false</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>(*it).prefix().first</P>
</TD>
<TD vAlign="top" width="50%">
<P>The end of the last match found, or the start of the underlying sequence if
this is the first match enumerated</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>(*it).prefix().last</P>
</TD>
<TD vAlign="top" width="50%">
<P>(*it)[0].first</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>(*it).prefix().matched</P>
</TD>
<TD vAlign="top" width="50%">
<P>(*it).prefix().first != (*it).prefix().second</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>(*it).suffix().first</P>
</TD>
<TD vAlign="top" width="50%">
<P>(*it)[0].second</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>(*it).suffix().last</P>
</TD>
<TD vAlign="top" width="50%">
<P>The end of the underlying sequence.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>(*it).suffix().matched</P>
</TD>
<TD vAlign="top" width="50%">
<P>(*it).suffix().first != (*it).suffix().second</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>(*it)[0].first</P>
</TD>
<TD vAlign="top" width="50%">
<P>The start of the sequence of characters that matched the regular expression</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>(*it)[0].second</P>
</TD>
<TD vAlign="top" width="50%">
<P>The end of the sequence of characters that matched the regular expression</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>(*it)[0].matched</P>
</TD>
<TD vAlign="top" width="50%">
<P>
<CODE>true</CODE> if a full match was found, and <CODE>false</CODE> if it was a
partial match (found as a result of the <CODE>match_partial</CODE> flag being
set).</P></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>(*it)[n].first</P>
</TD>
<TD vAlign="top" width="50%">
<P>For all integers n &lt; (*it).size(), the start of the sequence that matched
sub-expression <I>n</I>. Alternatively, if sub-expression n did not participate
in the match, then <I>last</I>.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>(*it)[n].second</P>
</TD>
<TD vAlign="top" width="50%">
<P>For all integers n &lt; (*it).size(), the end of the sequence that matched
sub-expression <I>n</I>. Alternatively, if sub-expression n did not participate
in the match, then <I>last</I>.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>(*it)[n].matched</P>
</TD>
<TD vAlign="top" width="50%">
<P>For all integers n &lt; (*it).size(), true if sub-expression <I>n</I> participated
in the match, false otherwise.</P>
</TD>
<TR>
<TD vAlign="top" width="50%">(*it).position(n)</TD>
<TD vAlign="top" width="50%">For all integers n &lt; (*it).size(), then the
distance from the start of the underlying sequence to the start of
sub-expression match <EM>n</EM>.</TD>
</TR>
</TBODY></TD></TR></TABLE></P><PRE>const value_type* operator-&gt;();</PRE>
<B>
<P>
Effects: </B>returns <CODE>&amp;(*this)</CODE>.</P><PRE>regex_iterator&amp; operator++();</PRE>
<P><STRONG>Effects:</STRONG> moves the iterator to the next match in the
match_flag_type m = match_default);
</pre>
<b></b>
<p><b>Effects:</b> constructs a regex_iterator that will enumerate all occurrences
of the expression <em>re</em>, within the sequence <em>[a,b)</em>, and found
using match flags <em>m</em>.&nbsp; The object <em>re</em> must exist for the
lifetime of the regex_iterator.</p>
<P><STRONG>Throws:</STRONG> <CODE>std::runtime_error</CODE> if the complexity of
matching the expression against an N character string begins to exceed O(N<SUP>2</SUP>),
or if the program runs out of stack space while matching the expression (if
Boost.regex is <A href="configuration.html">configured</A> in recursive mode),
or if the matcher exhausts it's permitted memory allocation (if Boost.regex is <A href="configuration.html">
configured</A> in non-recursive mode).</P>
<pre>
regex_iterator(const regex_iterator&amp; that);
</pre>
<b></b>
<p><b>Effects:</b> constructs a copy of <code>that</code>.</p>
<b></b>
<p><b>Postconditions:</b> <code>*this == that</code>.</p>
<pre>
regex_iterator&amp; operator=(const regex_iterator&amp;);
</pre>
<b></b>
<p><b>Effects:</b> sets&nbsp;<code>*this</code> equal to those in <code>that</code>.</p>
<b></b>
<p><b>Postconditions:</b> <code>*this == that</code>.</p>
<pre>
bool operator==(const regex_iterator&amp; that);
</pre>
<b></b>
<p><b>Effects:</b> returns true if *this is equal to that.</p>
<pre>
bool operator!=(const regex_iterator&amp;);
</pre>
<b></b>
<p><b>Effects:</b> returns <code>!(*this == that)</code>.</p>
<pre>
const value_type&amp; operator*();
</pre>
<p><b>Effects:</b> dereferencing a regex_iterator object <em>it</em> yields a
const reference to a <a href="match_results.html">match_results</a> object,
whose members are set as follows:</p>
<p></p>
<table id="Table2" cellspacing="1" cellpadding="7" width="624" border="1">
<tbody>
<tr>
<td valign="top" width="50%"><b></b>
<p><b>Element</b></p>
</td>
<td valign="top" width="50%"><b></b>
<p><b>Value</b></p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>(*it).size()</p>
</td>
<td valign="top" width="50%">
<p>re.mark_count()</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>(*it).empty()</p>
</td>
<td valign="top" width="50%">
<p>false</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>(*it).prefix().first</p>
</td>
<td valign="top" width="50%">
<p>The end of the last match found, or the start of the underlying sequence if
this is the first match enumerated</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>(*it).prefix().last</p>
</td>
<td valign="top" width="50%">
<p>(*it)[0].first</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>(*it).prefix().matched</p>
</td>
<td valign="top" width="50%">
<p>(*it).prefix().first != (*it).prefix().second</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>(*it).suffix().first</p>
</td>
<td valign="top" width="50%">
<p>(*it)[0].second</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>(*it).suffix().last</p>
</td>
<td valign="top" width="50%">
<p>The end of the underlying sequence.</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>(*it).suffix().matched</p>
</td>
<td valign="top" width="50%">
<p>(*it).suffix().first != (*it).suffix().second</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>(*it)[0].first</p>
</td>
<td valign="top" width="50%">
<p>The start of the sequence of characters that matched the regular expression</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>(*it)[0].second</p>
</td>
<td valign="top" width="50%">
<p>The end of the sequence of characters that matched the regular expression</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>(*it)[0].matched</p>
</td>
<td valign="top" width="50%">
<p><code>true</code> if a full match was found, and <code>false</code> if it was a
partial match (found as a result of the <code>match_partial</code> flag being
set).</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>(*it)[n].first</p>
</td>
<td valign="top" width="50%">
<p>For all integers n &lt; (*it).size(), the start of the sequence that matched
sub-expression <i>n</i>. Alternatively, if sub-expression n did not participate
in the match, then <i>last</i>.</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>(*it)[n].second</p>
</td>
<td valign="top" width="50%">
<p>For all integers n &lt; (*it).size(), the end of the sequence that matched
sub-expression <i>n</i>. Alternatively, if sub-expression n did not participate
in the match, then <i>last</i>.</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<p>(*it)[n].matched</p>
</td>
<td valign="top" width="50%">
<p>For all integers n &lt; (*it).size(), true if sub-expression <i>n</i> participated
in the match, false otherwise.</p>
</td>
</tr>
<tr>
<td valign="top" width="50%">(*it).position(n)</td>
<td valign="top" width="50%">For all integers n &lt; (*it).size(), then the
distance from the start of the underlying sequence to the start of
sub-expression match <em>n</em>.</td>
</tr>
</tbody>
</table>
<br>
<br>
<pre>
const value_type* operator-&gt;();
</pre>
<b></b>
<p><b>Effects:</b> returns <code>&amp;(*this)</code>.</p>
<pre>
regex_iterator&amp; operator++();
</pre>
<p><strong>Effects:</strong> moves the iterator to the next match in the
underlying sequence, or the end of sequence iterator if none if found.
&nbsp;When the last match found matched a zero length string, then the
regex_iterator will find the next match as follows: if there exists a non-zero
length match that starts at the same location as the last one, then returns it,
otherwise starts looking for the next (possibly zero length) match from one
position to the right of the last match.</P>
<B>
<P>
Returns:</B> <CODE>*this</CODE>.</P><PRE>regex_iterator operator++(int);</PRE>
<B>
<P>
Effects:</B> constructs a copy <CODE>result</CODE> of <CODE>*this</CODE>,
then calls <CODE>++(*this)</CODE>.</P><B>
<P>
Returns:</B> <CODE>result</CODE>.</P>
<H3>Examples</H3>
<P>The following <A href="../example/snippets/regex_iterator_example.cpp">example</A>
takes a C++ source file and builds up an index of class names, and the location
of that class in the file.</P>
position to the right of the last match.</p>
<P><STRONG>Throws:</STRONG> <CODE>std::runtime_error</CODE> if the complexity of
matching the expression against an N character string begins to exceed O(N<SUP>2</SUP>),
or if the program runs out of stack space while matching the expression (if
Boost.regex is <A href="configuration.html">configured</A> in recursive mode),
or if the matcher exhausts it's permitted memory allocation (if Boost.regex is <A href="configuration.html">
configured</A> in non-recursive mode).</P>
<b></b>
<p><b>Returns:</b> <code>*this</code>.</p>
<pre>
<FONT color=#008040>#include &lt;string&gt;</FONT>
<FONT color=#008040>#include &lt;map&gt;</FONT>
<FONT color=#008040>#include &lt;fstream&gt;</FONT>
<FONT color=#008040>#include &lt;iostream&gt;</FONT>
<FONT color=#008040>#include &lt;boost/regex.hpp&gt;</FONT>
regex_iterator operator++(int);
</pre>
<b></b>
<p><b>Effects:</b> constructs a copy <code>result</code> of <code>*this</code>,
then calls <code>++(*this)</code>.</p>
<b></b>
<p><b>Returns:</b> <code>result</code>.</p>
<h3>Examples</h3>
<p>The following <a href="../example/snippets/regex_iterator_example.cpp">example</a>
takes a C++ source file and builds up an index of class names, and the location
of that class in the file.</p>
<pre>
<font color="#008040">#include &lt;string&gt;</font>
<font color="#008040">#include &lt;map&gt;</font>
<font color="#008040">#include &lt;fstream&gt;</font>
<font color="#008040">#include &lt;iostream&gt;</font>
<font color="#008040">#include &lt;boost/regex.hpp&gt;</font>
<B>using</B> <B>namespace</B> std;
<b>using</b> <b>namespace</b> std;
<I><FONT color=#000080>// purpose:</FONT></I>
<I><FONT color=#000080>// takes the contents of a file in the form of a string</FONT></I>
<I><FONT color=#000080>// and searches for all the C++ class definitions, storing</FONT></I>
<I><FONT color=#000080>// their locations in a map of strings/int's</FONT></I>
<i><font color="#000080">// purpose:</font></i>
<i><font color=
#000080>// takes the contents of a file in the form of a string</font></i>
<i><font color=
#000080>// and searches for all the C++ class definitions, storing</font></i>
<i><font color=
#000080>// their locations in a map of strings/int's</font></i>
<B>typedef</B> std::map&lt;std::string, std::string::difference_type, std::less&lt;std::string&gt; &gt; map_type;
<b>typedef</b> std::map&lt;std::string, std::string::difference_type, std::less&lt;std::string&gt; &gt; map_type;
<B>const</B> <B>char</B>* re =
<I><FONT color=#000080>// possibly leading whitespace: </FONT></I>
<FONT color=#0000ff>"^[[:space:]]*"</FONT>
<I><FONT color=#000080>// possible template declaration:</FONT></I>
<FONT color=#0000ff>"(template[[:space:]]*&lt;[^;:{]+&gt;[[:space:]]*)?"</FONT>
<I><FONT color=#000080>// class or struct:</FONT></I>
<FONT color=#0000ff>"(class|struct)[[:space:]]*"</FONT>
<I><FONT color=#000080>// leading declspec macros etc:</FONT></I>
<FONT color=#0000ff>"("</FONT>
<FONT color=#0000ff>"\\&lt;\\w+\\&gt;"</FONT>
<FONT color=#0000ff>"("</FONT>
<FONT color=#0000ff>"[[:blank:]]*\\([^)]*\\)"</FONT>
<FONT color=#0000ff>")?"</FONT>
<FONT color=#0000ff>"[[:space:]]*"</FONT>
<FONT color=#0000ff>")*"</FONT>
<I><FONT color=#000080>// the class name</FONT></I>
<FONT color=#0000ff>"(\\&lt;\\w*\\&gt;)[[:space:]]*"</FONT>
<I><FONT color=#000080>// template specialisation parameters</FONT></I>
<FONT color=#0000ff>"(&lt;[^;:{]+&gt;)?[[:space:]]*"</FONT>
<I><FONT color=#000080>// terminate in { or :</FONT></I>
<FONT color=#0000ff>"(\\{|:[^;\\{()]*\\{)"</FONT>;
<b>const</b> <b>char</b>* re =
<i><font color=
#000080>// possibly leading whitespace: </font></i>
<font color="#0000ff">"^[[:space:]]*"</font>
<i><font color=
#000080>// possible template declaration:</font></i>
<font color=
#0000ff>"(template[[:space:]]*&lt;[^;:{]+&gt;[[:space:]]*)?"</font>
<i><font color="#000080">// class or struct:</font></i>
<font color="#0000ff">"(class|struct)[[:space:]]*"</font>
<i><font color=
#000080>// leading declspec macros etc:</font></i>
<font color="#0000ff">"("</font>
<font color="#0000ff">"\\&lt;\\w+\\&gt;"</font>
<font color="#0000ff">"("</font>
<font color="#0000ff">"[[:blank:]]*\\([^)]*\\)"</font>
<font color="#0000ff">")?"</font>
<font color="#0000ff">"[[:space:]]*"</font>
<font color="#0000ff">")*"</font>
<i><font color="#000080">// the class name</font></i>
<font color="#0000ff">"(\\&lt;\\w*\\&gt;)[[:space:]]*"</font>
<i><font color=
#000080>// template specialisation parameters</font></i>
<font color="#0000ff">"(&lt;[^;:{]+&gt;)?[[:space:]]*"</font>
<i><font color="#000080">// terminate in { or :</font></i>
<font color="#0000ff">"(\\{|:[^;\\{()]*\\{)"</font>;
boost::regex expression(re);
map_type class_index;
<B>bool</B> regex_callback(<B>const</B> boost::match_results&lt;std::string::const_iterator&gt;&amp; what)
<b>bool</b> regex_callback(<b>const</b> boost::match_results&lt;std::string::const_iterator&gt;&amp; what)
{
<I><FONT color=#000080>// what[0] contains the whole string</FONT></I>
<I><FONT color=#000080>// what[5] contains the class name.</FONT></I>
<I><FONT color=#000080>// what[6] contains the template specialisation if any.</FONT></I>
<I><FONT color=#000080>// add class name and position to map:</FONT></I>
class_index[what[<FONT color=#0000a0>5</FONT>].str() + what[<FONT color=#0000a0>6</FONT>].str()] = what.position(<FONT color=#0000a0>5</FONT>);
<B>return</B> <B>true</B>;
<i><font color=
#000080>// what[0] contains the whole string</font></i>
<i><font color=
#000080>// what[5] contains the class name.</font></i>
<i><font color=
#000080>// what[6] contains the template specialisation if any.</font></i>
<i><font color=
#000080>// add class name and position to map:</font></i>
class_index[what[<font color=
#0000a0>5</font>].str() + what[<font color=
#0000a0>6</font>].str()] = what.position(<font color=
#0000a0>5</font>);
<b>return</b> <b>true</b>;
}
<B>void</B> load_file(std::string&amp; s, std::istream&amp; is)
<b>void</b> load_file(std::string&amp; s, std::istream&amp; is)
{
s.erase();
s.reserve(is.rdbuf()-&gt;in_avail());
<B>char</B> c;
<B>while</B>(is.get(c))
<b>char</b> c;
<b>while</b>(is.get(c))
{
<B>if</B>(s.capacity() == s.size())
s.reserve(s.capacity() * <FONT color=#0000a0>3</FONT>);
s.append(<FONT color=#0000a0>1</FONT>, c);
<b>if</b>(s.capacity() == s.size())
s.reserve(s.capacity() * <font color="#0000a0">3</font>);
s.append(<font color="#0000a0">1</font>, c);
}
}
<B>int</B> main(<B>int</B> argc, <B>const</B> <B>char</B>** argv)
<b>int</b> main(<b>int</b> argc, <b>const</b> <b>char</b>** argv)
{
std::string text;
<B>for</B>(<B>int</B> i = <FONT color=#0000a0>1</FONT>; i &lt; argc; ++i)
<b>for</b>(<b>int</b> i = <font color=
#0000a0>1</font>; i &lt; argc; ++i)
{
cout &lt;&lt; <FONT color=#0000ff>"Processing file "</FONT> &lt;&lt; argv[i] &lt;&lt; endl;
cout &lt;&lt; <font color=
#0000ff>"Processing file "</font> &lt;&lt; argv[i] &lt;&lt; endl;
std::ifstream fs(argv[i]);
load_file(text, fs);
<I><FONT color=#000080>// construct our iterators:</FONT></I>
<i><font color=
#000080>// construct our iterators:</font></i>
boost::regex_iterator&lt;std::string::const_iterator&gt; m1(text.begin(), text.end(), expression);
boost::regex_iterator&lt;std::string::const_iterator&gt; m2;
std::for_each(m1, m2, <20>ex_callback);
<I><FONT color=#000080>// copy results:</FONT></I>
cout &lt;&lt; class_index.size() &lt;&lt; <FONT color=#0000ff>" matches found"</FONT> &lt;&lt; endl;
<i><font color="#000080">// copy results:</font></i>
cout &lt;&lt; class_index.size() &lt;&lt; <font color=
#0000ff>" matches found"</font> &lt;&lt; endl;
map_type::iterator c, d;
c = class_index.begin();
d = class_index.end();
<B>while</B>(c != d)
<b>while</b>(c != d)
{
cout &lt;&lt; <FONT color=#0000ff>"class \""</FONT> &lt;&lt; (*c).first &lt;&lt; <FONT color=#0000ff>"\" found at index: "</FONT> &lt;&lt; (*c).second &lt;&lt; endl;
cout &lt;&lt; <font color=
#0000ff>"class \""</font> &lt;&lt; (*c).first &lt;&lt; <font
color=
#0000ff>"\" found at index: "</font> &lt;&lt; (*c).second &lt;&lt; endl;
++c;
}
class_index.erase(class_index.begin(), class_index.end());
}
<B>return</B> <FONT color=#0000a0>0</FONT>;
<b>return</b> <font color="#0000a0">0</font>;
}
</pre>
<HR>
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
<p><i><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
<p align="left"><i>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
for any purpose. It is provided "as is" without express or implied warranty.</i></p>
</body>
</html>

View File

@ -26,17 +26,16 @@
<p></p>
<H3>Contents</H3>
<dl class="index">
<dt><a href="#synopsis">Synopsis</a></dt>
<dt><a href="#description">Description</a></dt>
<dt><a href="#examples">Examples</a></dt>
<dt><a href="#synopsis">Synopsis</a> <dt><a href="#description">Description</a> <dt><a href="#examples">
Examples</a></dt>
</dl>
<H3><A name="synopsis"></A>Synopsis</H3>
<PRE><A name=query_match></A>#include &lt;<A href="../../boost/regex.hpp">boost/regex.hpp</A>&gt; </PRE>
<P>The algorithm regex _match determines whether a given regular expression
matches a given sequence denoted by a pair of bidirectional-iterators, the
algorithm is defined as follows, <EM><FONT color="red">note that the result is true
only if the expression matches the whole of the input sequence</FONT></EM>,
the main use of this function is data input validation.
algorithm is defined as follows, <STRONG>note that the result is true only if the
expression matches the whole of the input sequence</STRONG>, the main use of
this function is data input validation.
<PRE>template &lt;class BidirectionalIterator, class Allocator, class charT,
class traits, class Allocator2&gt;
bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
@ -47,7 +46,7 @@ bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
template &lt;class BidirectionalIterator, class charT, class traits, class Allocator2&gt;
bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</a> flags = match_default);
<A href="match_flag_type.html">match_flag_type</A> flags = match_default);
template &lt;class charT, class Allocator, class traits, class Allocator2&gt;
bool regex_match(const charT* str, <A href="match_results.html">match_results</A>&lt;const charT*, Allocator&gt;&amp; m,
@ -78,201 +77,194 @@ bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
<A href="match_results.html">match_results</A>&lt;BidirectionalIterator, Allocator&gt;&amp; m,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</A> flags = match_default);</PRE>
<B>
<P>
Requires:</B> Type BidirectionalIterator meets the requirements of a
<P><B> Requires:</B> Type BidirectionalIterator meets the requirements of a
Bidirectional Iterator (24.1.4).</P>
<B>
<P>
Effects: </B>Determines whether there is an exact match between the regular
expression <I>e</I>, and all of the character sequence [first, last), parameter <I>
flags</I> is used to <A href="match_flag_type.html">control how the expression
is matched</A> against the character sequence. Returns true if such a match
exists, false otherwise.</P><B>
<P>
Postconditions: </B>If the function returns false, then the effect on
parameter <I>m</I> is undefined, otherwise the effects on parameter <I>m</I> are
given in the table:</P> <I>
<P>
<DIV align="center">
<P></P>
</I>
<P><B> Effects: </B>Determines whether there is an exact match between the regular
expression <I>e</I>, and all of the character sequence [first, last), parameter <I>
flags</I> is used to <A href="match_flag_type.html">control how the expression
is matched</A> against the character sequence. Returns true if such a match
exists, false otherwise.</P>
<P><STRONG>Throws:</STRONG> <code>std::runtime_error</code> if the complexity of matching the
expression against an N character string begins to exceed O(N<SUP>2</SUP>), or
if the program runs out of stack space while matching the expression (if
Boost.regex is <A href="configuration.html">configured</A> in recursive mode),
or if the matcher exhausts it's permitted memory allocation (if Boost.regex is <A href="configuration.html">
configured</A> in non-recursive mode).</P>
<P><B> Postconditions: </B>If the function returns false, then the effect on
parameter <I>m</I> is undefined, otherwise the effects on parameter <I>m</I> are
given in the table:</P>
<P align="center">
<CENTER>
<TABLE id="Table2" cellSpacing="1" cellPadding="7" width="624" border="1">
<TBODY>
<TR>
<TD vAlign="top" width="50%"><B>
<P>
Element</B>
</P>
</TD>
<TD vAlign="top" width="50%"><B>
<P>
Value</B> </P></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.size()</P>
</TD>
<TD vAlign="top" width="50%">
<P>e.mark_count()</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.empty()</P>
</TD>
<TD vAlign="top" width="50%">
<P>false</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.prefix().first</P>
</TD>
<TD vAlign="top" width="50%">
<P>first</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.prefix().last</P>
</TD>
<TD vAlign="top" width="50%">
<P>first</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.prefix().matched</P>
</TD>
<TD vAlign="top" width="50%">
<P>false</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.suffix().first</P>
</TD>
<TD vAlign="top" width="50%">
<P>last</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.suffix().last</P>
</TD>
<TD vAlign="top" width="50%">
<P>last</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.suffix().matched</P>
</TD>
<TD vAlign="top" width="50%">
<P>false</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[0].first</P>
</TD>
<TD vAlign="top" width="50%">
<P>first</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[0].second</P>
</TD>
<TD vAlign="top" width="50%">
<P>last</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[0].matched</P>
</TD>
<TD vAlign="top" width="50%"><CODE>
<P>
true</CODE> if a full match was found, and <CODE>false</CODE> if it was a
partial match (found as a result of the <CODE>match_partial</CODE> flag being
set).</P></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[n].first</P>
</TD>
<TD vAlign="top" width="50%">
<P>For all integers n &lt; m.size(), the start of the sequence that matched
sub-expression <I>n</I>. Alternatively, if sub-expression n did not participate
in the match, then <I>last</I>.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[n].second</P>
</TD>
<TD vAlign="top" width="50%">
<P>For all integers n &lt; m.size(), the end of the sequence that matched
sub-expression <I>n</I>. Alternatively, if sub-expression n did not participate
in the match, then <I>last</I>.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[n].matched</P>
</TD>
<TD vAlign="top" width="50%">
<P>For all integers n &lt; m.size(), true if sub-expression <I>n</I> participated
in the match, false otherwise.</P>
<P></P>
</TD>
</TR>
</TBODY></TD></TR></TABLE></CENTER>
<TD vAlign="top" width="50%">
<P><B> Element</B>
</P>
</TD>
<TD vAlign="top" width="50%">
<P><B> Value</B>
</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.size()</P>
</TD>
<TD vAlign="top" width="50%">
<P>e.mark_count()</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.empty()</P>
</TD>
<TD vAlign="top" width="50%">
<P>false</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.prefix().first</P>
</TD>
<TD vAlign="top" width="50%">
<P>first</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.prefix().last</P>
</TD>
<TD vAlign="top" width="50%">
<P>first</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.prefix().matched</P>
</TD>
<TD vAlign="top" width="50%">
<P>false</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.suffix().first</P>
</TD>
<TD vAlign="top" width="50%">
<P>last</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.suffix().last</P>
</TD>
<TD vAlign="top" width="50%">
<P>last</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.suffix().matched</P>
</TD>
<TD vAlign="top" width="50%">
<P>false</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[0].first</P>
</TD>
<TD vAlign="top" width="50%">
<P>first</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[0].second</P>
</TD>
<TD vAlign="top" width="50%">
<P>last</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[0].matched</P>
</TD>
<TD vAlign="top" width="50%">
<P><CODE> true</CODE> if a full match was found, and <CODE>false</CODE> if it was
a partial match (found as a result of the <CODE>match_partial</CODE> flag being
set).</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[n].first</P>
</TD>
<TD vAlign="top" width="50%">
<P>For all integers n &lt; m.size(), the start of the sequence that matched
sub-expression <I>n</I>. Alternatively, if sub-expression n did not participate
in the match, then <I>last</I>.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[n].second</P>
</TD>
<TD vAlign="top" width="50%">
<P>For all integers n &lt; m.size(), the end of the sequence that matched
sub-expression <I>n</I>. Alternatively, if sub-expression n did not participate
in the match, then <I>last</I>.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[n].matched</P>
</TD>
<TD vAlign="top" width="50%">
<P>For all integers n &lt; m.size(), true if sub-expression <I>n</I> participated
in the match, false otherwise.</P>
</TD>
</TR>
</TBODY></TD></TR></TABLE>
</CENTER>
<P></P>
</DIV><PRE>template &lt;class BidirectionalIterator, class charT, class traits, class Allocator2&gt;
<DIV></DIV>
<PRE>&nbsp;</PRE>
<PRE>template &lt;class BidirectionalIterator, class charT, class traits, class Allocator2&gt;
bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</A> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Behaves "as if" by constructing an instance of <CODE><A href="match_results.html">
match_results</A>&lt;</CODE>BidirectionalIterator<CODE>&gt; what</CODE>,
and then returning the result of <CODE>regex_match(first, last, what, e, flags)</CODE>.</P><PRE>template &lt;class charT, class Allocator, class traits, class Allocator2&gt;
<P><B> Effects:</B> Behaves "as if" by constructing an instance of <CODE><A href="match_results.html">
match_results</A>&lt;</CODE>BidirectionalIterator<CODE>&gt; what</CODE>,
and then returning the result of <CODE>regex_match(first, last, what, e, flags)</CODE>.</P>
<PRE>template &lt;class charT, class Allocator, class traits, class Allocator2&gt;
bool regex_match(const charT* str, <A href="match_results.html">match_results</A>&lt;const charT*, Allocator&gt;&amp; m,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</A> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>regex_match(str, str +
char_traits&lt;charT&gt;::length(str), m, e, flags)</CODE>.</P><PRE>template &lt;class ST, class SA, class Allocator, class charT,
<P><B> Effects:</B> Returns the result of <CODE>regex_match(str, str +
char_traits&lt;charT&gt;::length(str), m, e, flags)</CODE>.</P>
<PRE>template &lt;class ST, class SA, class Allocator, class charT,
class traits, class Allocator2&gt;
bool regex_match(const basic_string&lt;charT, ST, SA&gt;&amp; s,
<A href="match_results.html">match_results</A>&lt;typename basic_string&lt;charT, ST, SA&gt;::const_iterator, Allocator&gt;&amp; m,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</A> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>regex_match(s.begin(), s.end(), m, e,
flags)</CODE>.</P><PRE>template &lt;class charT, class traits, class Allocator2&gt;
<P><B> Effects:</B> Returns the result of <CODE>regex_match(s.begin(), s.end(), m, e,
flags)</CODE>.</P>
<PRE>template &lt;class charT, class traits, class Allocator2&gt;
bool regex_match(const charT* str,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</A> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>regex_match(str, str +
char_traits&lt;charT&gt;::length(str), e, flags)</CODE>.</P><PRE>template &lt;class ST, class SA, class charT, class traits, class Allocator2&gt;
<P><B> Effects:</B> Returns the result of <CODE>regex_match(str, str +
char_traits&lt;charT&gt;::length(str), e, flags)</CODE>.</P>
<PRE>template &lt;class ST, class SA, class charT, class traits, class Allocator2&gt;
bool regex_match(const basic_string&lt;charT, ST, SA&gt;&amp; s,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</A> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>regex_match(s.begin(), s.end(), e,
flags)</CODE>.
<H3><A name="examples"></A>Examples</H3>
<P><B> Effects:</B> Returns the result of <CODE>regex_match(s.begin(), s.end(), e,
flags)</CODE>.
<H3><A name="examples"></A>Examples</H3>
<P>The following <A href="../example/snippets/regex_match_example.cpp">example</A>
processes an ftp response:
<P></P>
@ -311,7 +303,7 @@ regex expression(<FONT color=#000080>"([0-9]+)(\\-| |$)(.*)"</FONT>);
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>

View File

@ -25,17 +25,17 @@
<HR>
<p></p>
<P>Algorithm regex_merge has been renamed <A href="regex_replace.html">regex_replace</A>,
existing code will continue to compile, but newcode should use <A href="regex_replace.html">
existing code will continue to compile, but new code should use <A href="regex_replace.html">
regex_replace</A> instead.</P>
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
@ -44,3 +44,4 @@
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -34,7 +34,7 @@
output iterator. Sections of text that do not match are copied to the output
unchanged only if the <EM>flags</EM> parameter does not have the flag <A href="match_flags.html">
format_no_copy</A> set. If the flag <A href="match_flags.html">format_first_only</A>
is set then only the first occurance is replaced rather than all
is set then only the first occurrence is replaced rather than all
occurrences.&nbsp;<PRE>template &lt;class OutputIterator, class BidirectionalIterator, class traits,
class Allocator, class charT&gt;
OutputIterator regex_replace(OutputIterator out,
@ -60,9 +60,7 @@ OutputIterator regex_replace(OutputIterator out,
const basic_regex&lt;charT, traits, Allocator&gt;&amp; e,
const basic_string&lt;charT&gt;&amp; fmt,
match_flag_type flags = match_default);</PRE>
<B>
<P>
Effects:</B> Finds all the non-overlapping matches <I>m</I> of type <CODE>match_results&lt;BidirectionalIterator&gt;
<P><B> Effects:</B> Finds all the non-overlapping matches <I>m</I> of type <CODE>match_results&lt;BidirectionalIterator&gt;
</CODE>that occur within the sequence [first, last). If no such matches are
found and <CODE>!(flags &amp; format_no_copy)</CODE> then calls <CODE>std::copy(first,
last, out)</CODE>. Otherwise, for each match found, if <CODE>!(flags &amp;
@ -72,19 +70,23 @@ OutputIterator regex_replace(OutputIterator out,
last_m,suffix().last, out) </CODE>where <CODE>last_m</CODE> is a copy of the
last match found. If <CODE>flags &amp; format_first_only</CODE> is non-zero
then only the first match found is replaced.</P>
<B>
<P>
Returns:</B> <CODE>out</CODE>. </P><PRE>template &lt;class traits, class Allocator, class charT&gt;
<P><STRONG>Throws:</STRONG> <CODE>std::runtime_error</CODE> if the complexity of
matching the expression against an N character string begins to exceed O(N<SUP>2</SUP>),
or if the program runs out of stack space while matching the expression (if
Boost.regex is <A href="configuration.html">configured</A> in recursive mode),
or if the matcher exhausts it's permitted memory allocation (if Boost.regex is <A href="configuration.html">
configured</A> in non-recursive mode).</P>
<P><B> Returns:</B> <CODE>out</CODE>.
</P>
<PRE>template &lt;class traits, class Allocator, class charT&gt;
basic_string&lt;charT&gt; regex_replace(const basic_string&lt;charT&gt;&amp; s,
const basic_regex&lt;charT, traits, Allocator&gt;&amp; e,
const basic_string&lt;charT&gt;&amp; fmt,
match_flag_type flags = match_default);</PRE>
<B>
<P>
Effects:</B> Constructs an object <CODE>basic_string&lt;charT&gt; result</CODE>,
calls <CODE>regex_replace(back_inserter(result), s.begin(), s.end(), e, fmt,
flags)</CODE>, and then returns <CODE>result</CODE>.
<H3><A name="examples"></A>Examples</H3>
<P><B> Effects:</B> Constructs an object <CODE>basic_string&lt;charT&gt; result</CODE>,
calls <CODE>regex_replace(back_inserter(result), s.begin(), s.end(), e, fmt,
flags)</CODE>, and then returns <CODE>result</CODE>.
<H3><A name="examples"></A>Examples</H3>
<P>The following <A href="../example/snippets/regex_replace_example.cpp">example</A>
takes C/C++ source code as input, and outputs syntax highlighted HTML code.</P>
<P></P>
@ -193,10 +195,11 @@ boost::regex e1, e2;
</FONT> <FONT color=#0000ff>"&lt;P&gt; &lt;/P&gt;\n&lt;PRE&gt;"</FONT>;
<B>const</B> <B>char</B>* footer_text = <FONT color=#0000ff>"&lt;/PRE&gt;\n&lt;/BODY&gt;\n\n"</FONT>;
<HR></PRE>
</PRE>
<HR>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>

View File

@ -38,77 +38,79 @@
class Allocator, class charT,
class traits, class Allocator2&gt;
bool regex_search(BidirectionalIterator first, BidirectionalIterator last,
<a href=match_results.html>match_results</a>&lt;BidirectionalIterator, Allocator&gt;&amp; m,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator2&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);
<a href="match_results.html">match_results</a>&lt;BidirectionalIterator, Allocator&gt;&amp; m,
const <a href="basic_regex.html">basic_regex</a>&lt;charT, traits, Allocator2&gt;&amp; e,
<a href="match_flag_type.html">match_flag_type</a> flags = match_default);
template &lt;class ST, class SA,
class Allocator, class charT,
class traits, class Allocator2&gt;
bool regex_search(const basic_string&lt;charT, ST, SA&gt;&amp; s,
<a href=match_results.html>match_results</a>&lt;
<a href="match_results.html">match_results</a>&lt;
typename basic_string&lt;charT, ST,SA&gt;::const_iterator,
Allocator&gt;&amp; m,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator2&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);
const <a href="basic_regex.html">basic_regex</a>&lt;charT, traits, Allocator2&gt;&amp; e,
<a href="match_flag_type.html">match_flag_type</a> flags = match_default);
template&lt;class charT, class Allocator, class traits,
class Allocator2&gt;
bool regex_search(const charT* str,
<a href=match_results.html>match_results</a>&lt;const charT*, Allocator&gt;&amp; m,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator2&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);
<a href="match_results.html">match_results</a>&lt;const charT*, Allocator&gt;&amp; m,
const <a href="basic_regex.html">basic_regex</a>&lt;charT, traits, Allocator2&gt;&amp; e,
<a href="match_flag_type.html">match_flag_type</a> flags = match_default);
template &lt;class BidirectionalIterator, class Allocator,
class charT, class traits&gt;
bool regex_search(BidirectionalIterator first, BidirectionalIterator last,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);
const <a href="basic_regex.html">basic_regex</a>&lt;charT, traits, Allocator&gt;&amp; e,
<a href="match_flag_type.html">match_flag_type</a> flags = match_default);
template &lt;class charT, class Allocator,
class traits&gt;
bool regex_search(const charT* str,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);
const <a href="basic_regex.html">basic_regex</a>&lt;charT, traits, Allocator&gt;&amp; e,
<a href="match_flag_type.html">match_flag_type</a> flags = match_default);
template&lt;class ST, class SA,
class Allocator, class charT,
class traits&gt;
bool regex_search(const basic_string&lt;charT, ST, SA&gt;&amp; s,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);
const <a href="basic_regex.html">basic_regex</a>&lt;charT, traits, Allocator&gt;&amp; e,
<a href="match_flag_type.html">match_flag_type</a> flags = match_default);
</PRE>
<H3><A name="description"></A>Description</H3>
<PRE>template &lt;class BidirectionalIterator, class Allocator, class charT,
class traits, class Allocator2&gt;
bool regex_search(BidirectionalIterator first, BidirectionalIterator last,
<a href=match_results.html>match_results</a>&lt;BidirectionalIterator, Allocator&gt;&amp; m,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator2&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);</PRE>
<B>
<P>
Requires:</B> Type BidirectionalIterator meets the requirements of a
<a href="match_results.html">match_results</a>&lt;BidirectionalIterator, Allocator&gt;&amp; m,
const <a href="basic_regex.html">basic_regex</a>&lt;charT, traits, Allocator2&gt;&amp; e,
<a href="match_flag_type.html">match_flag_type</a> flags = match_default);</PRE>
<P><B> Requires:</B> Type BidirectionalIterator meets the requirements of a
Bidirectional Iterator (24.1.4).</P>
<B>
<P>
Effects: </B>Determines whether there is some sub-sequence within
[first,last) that matches the regular expression <I>e</I>, parameter <I>flags</I>
is used to control how the expression is matched against the character
sequence. Returns true if such a sequence exists, false otherwise.</P><B>
<P>
Postconditions: </B>If the function returns false, then the effect on
parameter <I>m</I> is undefined, otherwise the effects on parameter <I>m</I> are
given in the table:</P>
<P><B> Effects: </B>Determines whether there is some sub-sequence within
[first,last) that matches the regular expression <I>e</I>, parameter <I>flags</I>
is used to control how the expression is matched against the character
sequence. Returns true if such a sequence exists, false otherwise.</P>
<P><STRONG>Throws:</STRONG> <CODE>std::runtime_error</CODE> if the complexity of
matching the expression against an N character string begins to exceed O(N<SUP>2</SUP>),
or if the program runs out of stack space while matching the expression (if
Boost.regex is <A href="configuration.html">configured</A> in recursive mode),
or if the matcher exhausts it's permitted memory allocation (if Boost.regex is <A href="configuration.html">
configured</A> in non-recursive mode).</P>
<P><B> Postconditions: </B>If the function returns false, then the effect on
parameter <I>m</I> is undefined, otherwise the effects on parameter <I>m</I> are
given in the table:</P>
<DIV align="center">
<CENTER>
<TABLE id="Table2" cellSpacing="1" cellPadding="7" width="624" border="1">
<TR>
<TD vAlign="top" width="50%"><B>
<P>
Element</B></P></TD>
<TD vAlign="top" width="50%"><B>
<P>
Value</B> </P></TD>
<TD vAlign="top" width="50%">
<P><B> Element</B></P>
</TD>
<TD vAlign="top" width="50%">
<P><B> Value</B>
</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
@ -194,11 +196,11 @@ bool regex_search(BidirectionalIterator first, BidirectionalIterator last,
<TD vAlign="top" width="50%">
<P>m[0].matched</P>
</TD>
<TD vAlign="top" width="50%"><CODE>
<P>
true</CODE> if a full match was found, and <CODE>false</CODE> if it was a
partial match (found as a result of the <CODE>match_partial</CODE> flag being
set).</P></TD>
<TD vAlign="top" width="50%">
<P><CODE> true</CODE> if a full match was found, and <CODE>false</CODE> if it was
a partial match (found as a result of the <CODE>match_partial</CODE> flag being
set).</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
@ -227,54 +229,47 @@ bool regex_search(BidirectionalIterator first, BidirectionalIterator last,
<TD vAlign="top" width="50%">
<P>For all integers n &lt; m.size(), true if sub-expression <I>n</I> participated
in the match, false otherwise.</P>
<P></P>
</TD>
</TR>
</TD></TR></TABLE>
</CENTER>
</DIV>
<PRE>template &lt;class charT, class Allocator, class traits, class Allocator2&gt;
bool regex_search(const charT* str, <a href=match_results.html>match_results</a>&lt;const charT*, Allocator&gt;&amp; m,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator2&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>regex_search(str, str +
char_traits&lt;charT&gt;::length(str), m, e, flags)</CODE>.</P><PRE>template &lt;class ST, class SA, class Allocator, class charT,
bool regex_search(const charT* str, <a href="match_results.html">match_results</a>&lt;const charT*, Allocator&gt;&amp; m,
const <a href="basic_regex.html">basic_regex</a>&lt;charT, traits, Allocator2&gt;&amp; e,
<a href="match_flag_type.html">match_flag_type</a> flags = match_default);</PRE>
<P><B> Effects:</B> Returns the result of <CODE>regex_search(str, str +
char_traits&lt;charT&gt;::length(str), m, e, flags)</CODE>.</P>
<PRE>template &lt;class ST, class SA, class Allocator, class charT,
class traits, class Allocator2&gt;
bool regex_search(const basic_string&lt;charT, ST, SA&gt;&amp; s,
<a href=match_results.html>match_results</a>&lt;typename basic_string&lt;charT, ST, SA&gt;::const_iterator, Allocator&gt;&amp; m,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator2&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>regex_search(s.begin(), s.end(), m, e,
flags)</CODE>.</P><PRE>template &lt;class iterator, class Allocator, class charT,
<a href="match_results.html">match_results</a>&lt;typename basic_string&lt;charT, ST, SA&gt;::const_iterator, Allocator&gt;&amp; m,
const <a href="basic_regex.html">basic_regex</a>&lt;charT, traits, Allocator2&gt;&amp; e,
<a href="match_flag_type.html">match_flag_type</a> flags = match_default);</PRE>
<P><B> Effects:</B> Returns the result of <CODE>regex_search(s.begin(), s.end(), m,
e, flags)</CODE>.</P>
<PRE>template &lt;class iterator, class Allocator, class charT,
class traits&gt;
bool regex_search(iterator first, iterator last,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Behaves "as if" by constructing an instance of <CODE><a href="match_results.html">
match_results</a>&lt;</CODE>BidirectionalIterator<CODE>&gt; what</CODE>,
and then returning the result of <CODE>regex_search(first, last, what, e, flags)</CODE>.</P><PRE>template &lt;class charT, class Allocator, class traits&gt;
const <a href="basic_regex.html">basic_regex</a>&lt;charT, traits, Allocator&gt;&amp; e,
<a href="match_flag_type.html">match_flag_type</a> flags = match_default);</PRE>
<P><B> Effects:</B> Behaves "as if" by constructing an instance of <CODE><a href="match_results.html">
match_results</a>&lt;</CODE>BidirectionalIterator<CODE>&gt; what</CODE>,
and then returning the result of <CODE>regex_search(first, last, what, e, flags)</CODE>.</P>
<PRE>template &lt;class charT, class Allocator, class traits&gt;
bool regex_search(const charT* str
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>regex_search(str, str +
char_traits&lt;charT&gt;::length(str), e, flags)</CODE>.</P><PRE>template &lt;class ST, class SA, class Allocator, class charT,
const <a href="basic_regex.html">basic_regex</a>&lt;charT, traits, Allocator&gt;&amp; e,
<a href="match_flag_type.html">match_flag_type</a> flags = match_default);</PRE>
<P><B> Effects:</B> Returns the result of <CODE>regex_search(str, str +
char_traits&lt;charT&gt;::length(str), e, flags)</CODE>.</P>
<PRE>template &lt;class ST, class SA, class Allocator, class charT,
class traits&gt;
bool regex_search(const basic_string&lt;charT, ST, SA&gt;&amp; s,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>regex_search(s.begin(), s.end(), e,
flags)</CODE>.
<H3><A name="examples"></A>Examples</H3>
const <a href="basic_regex.html">basic_regex</a>&lt;charT, traits, Allocator&gt;&amp; e,
<a href="match_flag_type.html">match_flag_type</a> flags = match_default);</PRE>
<P><B> Effects:</B> Returns the result of <CODE>regex_search(s.begin(), s.end(), e,
flags)</CODE>.
<H3><A name="examples"></A>Examples</H3>
<P>The following <A href="../example/snippets/regex_search_example.cpp">example</A>,
takes the contents of a file in the form of a string, and searches for all the
C++ class declarations in the file. The code will work regardless of the way
@ -298,7 +293,7 @@ void</B> IndexClasses(map_type&amp; m, <B>const</B> std::string&amp; file)
&nbsp;&nbsp; std::string::const_iterator start, end;
&nbsp;&nbsp; start = file.begin();
&nbsp;&nbsp; end = file.end();&nbsp;
&nbsp;&nbsp; &nbsp;&nbsp; boost::<a href=match_results.html>match_results</a>&lt;std::string::const_iterator&gt; what;
&nbsp;&nbsp; &nbsp;&nbsp; boost::<a href="match_results.html">match_results</a>&lt;std::string::const_iterator&gt; what;
&nbsp;&nbsp; <B>unsigned</B> <B>int</B> flags = boost::match_default;
&nbsp;&nbsp; <B>while</B>(regex_search(start, end, what, expression, flags))&nbsp;
&nbsp;&nbsp; {
@ -315,13 +310,14 @@ void</B> IndexClasses(map_type&amp; m, <B>const</B> std::string&amp; file)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; flags |= boost::match_not_bob;&nbsp;
&nbsp;&nbsp; }
}
<HR></PRE>
</PRE>
<HR>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that

View File

@ -24,7 +24,7 @@
</P>
<HR>
<p></p>
<P>The algorithm regex_split has been deprecated in favour of the iterator <A href="regex_token_iterator.html">
<P>The algorithm regex_split has been deprecated in favor of the iterator <A href="regex_token_iterator.html">
regex_token_iterator</A> which has a more flexible and powerful interface,
as well as following the more usual standard library "pull" rather than "push"
semantics.</P>
@ -51,30 +51,37 @@ std::size_t regex_split(OutputIterator out,&nbsp;
<B>template</B> &lt;<B>class</B> OutputIterator, <B>class</B> charT, <B>class</B> Traits1, <B>class</B> Alloc1&gt;
std::size_t regex_split(OutputIterator out,
std::basic_string&lt;charT, Traits1, Alloc1&gt;&amp; s);</PRE>
<P>Each version takes an output-iterator for output, and a string for input. If
the expression contains no marked sub-expressions, then the algorithm writes
one string onto the output-iterator for each section of input that does not
match the expression. If the expression does contain marked sub-expressions,
then each time a match is found, one string for each marked sub-expression will
be written to the output-iterator. No more than <I>max_split </I>strings will
be written to the output-iterator. Before returning, all the input processed
will be deleted from the string <I>s</I> (if <I>max_split </I>is not reached
then all of <I>s</I> will be deleted). Returns the number of strings written to
the output-iterator. If the parameter <I>max_split</I> is not specified then it
defaults to UINT_MAX. If no expression is specified, then it defaults to "\s+",
and splitting occurs on whitespace.
<P><STRONG>Effects: </STRONG>Each version of the algorithm takes an
output-iterator for output, and a string for input. If the expression contains
no marked sub-expressions, then the algorithm writes one string onto the
output-iterator for each section of input that does not match the expression.
If the expression does contain marked sub-expressions, then each time a match
is found, one string for each marked sub-expression will be written to the
output-iterator. No more than <I>max_split </I>strings will be written to the
output-iterator. Before returning, all the input processed will be deleted from
the string <I>s</I> (if <I>max_split </I>is not reached then all of <I>s</I> will
be deleted). Returns the number of strings written to the output-iterator. If
the parameter <I>max_split</I> is not specified then it defaults to UINT_MAX.
If no expression is specified, then it defaults to "\s+", and splitting occurs
on whitespace.
</P>
<P><A href="../example/snippets/regex_split_example_1.cpp">Example</A>: the following
function will split the input string into a series of tokens, and remove each
token from the string <I>s</I>:
<P><STRONG>Throws:</STRONG> <CODE>std::runtime_error</CODE> if the complexity of
matching the expression against an N character string begins to exceed O(N<SUP>2</SUP>),
or if the program runs out of stack space while matching the expression (if
Boost.regex is <A href="configuration.html">configured</A> in recursive mode),
or if the matcher exhausts it's permitted memory allocation (if Boost.regex is <A href="configuration.html">
configured</A> in non-recursive mode).</P>
<P><A href="../example/snippets/regex_split_example_1.cpp">Example</A>: the
following function will split the input string into a series of tokens, and
remove each token from the string <I>s</I>:
</P>
<PRE><B>unsigned</B> tokenise(std::list&lt;std::string&gt;&amp; l, std::string&amp; s)
{
<B>&nbsp;&nbsp; return</B> boost::regex_split(std::back_inserter(l), s);
}</PRE>
<P><A href="../example/snippets/regex_split_example_2.cpp">Example</A>: the following
short program will extract all of the URL's from a html file, and print them
out to <I>cout</I>:
<P><A href="../example/snippets/regex_split_example_2.cpp">Example</A>: the
following short program will extract all of the URL's from a html file, and
print them out to <I>cout</I>:
</P>
<PRE><FONT color=#008000>#include &lt;list&gt;
#include &lt;fstream&gt;
@ -124,15 +131,13 @@ boost::regex e(<FONT color=#000080>"&lt;\\s*A\\s+[^&gt;]*href\\s*=\\s*\"([^\"]*)
}
<B>return</B> 0;
}</PRE>
<P>
<HR>
<P></P>
<HR>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that

View File

@ -72,40 +72,44 @@ public:
</PRE>
<H3><A name="description"></A>Description</H3>
<PRE>regex_token_iterator();</PRE>
<B>
<P>
Effects:</B> constructs an end of sequence iterator.</P><PRE>regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type&amp; re,
<P><B> Effects:</B> constructs an end of sequence iterator.</P>
<PRE>regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type&amp; re,
int submatch = 0, match_flag_type m = match_default);</PRE>
<B>
<P>
Preconditions: </B><CODE>!re.empty()</CODE>.</P><B>
<P>
Effects:</B> constructs a regex_token_iterator that will enumerate one
string for each regular expression match of the expression <EM>re</EM> found
within the sequence <EM>[a,b)</EM>, using match flags <EM>m</EM>.&nbsp; The
string enumerated is the&nbsp;sub-expression <EM>submatch </EM>for each match
found; if <EM>submatch </EM>is -1, then enumerates all the text sequences that
did not match the expression <EM>re </EM>(that is to performs field
splitting).</P><PRE>regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type&amp; re,
<P><B> Preconditions: </B><CODE>!re.empty()</CODE>.</P>
<P><B> Effects:</B> constructs a regex_token_iterator that will enumerate one
string for each regular expression match of the expression <EM>re</EM> found
within the sequence <EM>[a,b)</EM>, using match flags <EM>m</EM>.&nbsp; The
string enumerated is the&nbsp;sub-expression <EM>submatch </EM>for each match
found; if <EM>submatch </EM>is -1, then enumerates all the text sequences that
did not match the expression <EM>re </EM>(that is to performs field splitting).</P>
<P><STRONG>Throws:</STRONG> <CODE>std::runtime_error</CODE> if the complexity of
matching the expression against an N character string begins to exceed O(N<SUP>2</SUP>),
or if the program runs out of stack space while matching the expression (if
Boost.regex is <A href="configuration.html">configured</A> in recursive mode),
or if the matcher exhausts it's permitted memory allocation (if Boost.regex is <A href="configuration.html">
configured</A> in non-recursive mode).</P>
<PRE>regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type&amp; re,
const std::vector&lt;int&gt;&amp; submatches, match_flag_type m = match_default);</PRE>
<B>
<P>
Preconditions:</B> <CODE>submatches.size() &amp;&amp; !re.empty()</CODE>.</P><B>
<P>
Effects:</B> constructs a regex_token_iterator that will enumerate <EM>submatches.size()</EM>
strings for each regular expression match of the expression <EM>re</EM> found
within the sequence <EM>[a,b)</EM>, using match flags <EM>m</EM>.&nbsp; For
each match found one string will be enumerated&nbsp;for each sub-expression
index&nbsp;contained within <EM>submatches </EM>vector; if <EM>submatches[0] </EM>
is -1, then the first string enumerated for each match will be all of the text
from end of the last match to the start of the current match, in addition there
will be one extra string enumerated when no more matches can be found: from the
end of the last match found, to the end of the underlying sequence.</P><PRE>template &lt;std::size_t N&gt;
<P><B> Preconditions:</B> <CODE>submatches.size() &amp;&amp; !re.empty()</CODE>.</P>
<P><B> Effects:</B> constructs a regex_token_iterator that will enumerate <EM>submatches.size()</EM>
strings for each regular expression match of the expression <EM>re</EM> found
within the sequence <EM>[a,b)</EM>, using match flags <EM>m</EM>.&nbsp; For
each match found one string will be enumerated&nbsp;for each sub-expression
index&nbsp;contained within <EM>submatches </EM>vector; if <EM>submatches[0] </EM>
is -1, then the first string enumerated for each match will be all of the text
from end of the last match to the start of the current match, in addition there
will be one extra string enumerated when no more matches can be found: from the
end of the last match found, to the end of the underlying sequence.</P>
<P><STRONG>Throws:</STRONG> <CODE>std::runtime_error</CODE> if the complexity of
matching the expression against an N character string begins to exceed O(N<SUP>2</SUP>),
or if the program runs out of stack space while matching the expression (if
Boost.regex is <A href="configuration.html">configured</A> in recursive mode),
or if the matcher exhausts it's permitted memory allocation (if Boost.regex is <A href="configuration.html">
configured</A> in non-recursive mode).</P>
<PRE>template &lt;std::size_t N&gt;
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type&amp; re,
const int (&amp;submatches)[R], match_flag_type m = match_default);</PRE>
<B>
<P>
Preconditions: </B><CODE>!re.empty()</CODE>.</P>
<P><B> Preconditions: </B><CODE>!re.empty()</CODE>.</P>
<P><STRONG>Effects:</STRONG></B> constructs a regex_token_iterator that will
enumerate&nbsp;<EM>R</EM> strings for each regular expression match of the
expression <EM>re</EM> found within the sequence <EM>[a,b)</EM>, using match
@ -116,41 +120,46 @@ regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const reg
of the current match, in addition there will be one extra string enumerated
when no more matches can be found: from the end of the last match found, to the
end of the underlying sequence.</P>
<P><STRONG>Throws:</STRONG> <CODE>std::runtime_error</CODE> if the complexity of
matching the expression against an N character string begins to exceed O(N<SUP>2</SUP>),
or if the program runs out of stack space while matching the expression (if
Boost.regex is <A href="configuration.html">configured</A> in recursive mode),
or if the matcher exhausts it's permitted memory allocation (if Boost.regex is <A href="configuration.html">
configured</A> in non-recursive mode).</P>
<PRE>regex_token_iterator(const regex_token_iterator&amp; that);</PRE>
<P><B> Effects: </B>constructs a copy of <CODE>that</CODE>.</P>
<P><B> Postconditions:</B> <CODE>*this == that</CODE>.</P>
<PRE>regex_token_iterator&amp; operator=(const regex_token_iterator&amp; that);</PRE>
<P><B> Effects: </B>sets <CODE>*this</CODE> to be equal to&nbsp;<CODE>that</CODE>.</P>
<P><B> Postconditions:</B> <CODE>*this == that</CODE>.</P>
<PRE>bool operator==(const regex_token_iterator&amp;);</PRE>
<P>
<B>Effects: </B>returns true if *this is the same position as that.</P>
<PRE>bool operator!=(const regex_token_iterator&amp;);</PRE>
<P>
<B>Effects: </B>returns <CODE>!(*this == that)</CODE>.</P>
<PRE>const value_type&amp; operator*();</PRE>
<P>
<B>Effects: </B>returns the current string being enumerated.</P>
<PRE>const value_type* operator-&gt;();</PRE>
<P>
<B>Effects: </B>returns <CODE>&amp;(*this)</CODE>.</P>
<PRE>regex_token_iterator&amp; operator++();</PRE>
<P>
<B>Effects: </B>Moves on to the next string to be enumerated.</P>
<P><STRONG>Throws:</STRONG> <CODE>std::runtime_error</CODE> if the complexity of
matching the expression against an N character string begins to exceed O(N<SUP>2</SUP>),
or if the program runs out of stack space while matching the expression (if
Boost.regex is <A href="configuration.html">configured</A> in recursive mode),
or if the matcher exhausts it's permitted memory allocation (if Boost.regex is <A href="configuration.html">
configured</A> in non-recursive mode).</P>
<B>
<P>
Effects: </B>constructs a copy of <CODE>that</CODE>.</P><B>
<P>
Postconditions:</B> <CODE>*this == that</CODE>.</P><PRE>regex_token_iterator&amp; operator=(const regex_token_iterator&amp; that);</PRE>
<B>
<P>
Effects: </B>sets <CODE>*this</CODE> to be equal to&nbsp;<CODE>that</CODE>.</P><B>
<P>
Postconditions:</B> <CODE>*this == that</CODE>.</P><PRE>bool operator==(const regex_token_iterator&amp;);</PRE>
<B>
<P>
Effects: </B>returns true if *this is the same position as that.</P><PRE>bool operator!=(const regex_token_iterator&amp;);</PRE>
<B>
<P>
Effects: </B>returns <CODE>!(*this == that)</CODE>.</P><PRE>const value_type&amp; operator*();</PRE>
<B>
<P>
Effects: </B>returns the current string being enumerated.</P><PRE>const value_type* operator-&gt;();</PRE>
<B>
<P>
Effects: </B>returns <CODE>&amp;(*this)</CODE>.</P><PRE>regex_token_iterator&amp; operator++();</PRE>
<B>
<P>
Effects: </B>Moves on to the next string to be enumerated.</P><B>
<P>
Returns:</B><CODE> *this</CODE>.</P><PRE>regex_token_iterator&amp; operator++(int);</PRE>
<B>
<P>
Effects:</B> constructs a copy <CODE>result</CODE> of <CODE>*this</CODE>,
then calls <CODE>++(*this)</CODE>.</P><B>
<P>
Returns:</B> <CODE>result</CODE>.<A name="examples"></A>
<H3>Examples</H3>
<P><B> Effects:</B> constructs a copy <CODE>result</CODE> of <CODE>*this</CODE>,
then calls <CODE>++(*this)</CODE>.</P>
<P><B> Returns:</B> <CODE>result</CODE>.<A name="examples"></A>
<H3>Examples</H3>
<P>The following <A href="../example/snippets/regex_token_iterator_example_1.cpp">example</A>
takes a string and splits it into a series of tokens:</P>
<pre>
@ -260,12 +269,10 @@ boost::regex e(<FONT color=#0000ff>"&lt;\\s*A\\s+[^&gt;]*href\\s*=\\s*\"([^\"]*)
<B>return</B> <FONT color=#0000a0>0</FONT>;
}
</pre>
<P>
<HR>
<P></P>
<HR>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>

View File

@ -33,7 +33,7 @@
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
@ -45,3 +45,4 @@
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -23,10 +23,9 @@
</TABLE>
</P>
<HR>
<p></p>
<H3>C++</H3>
<P>Boost.regex is intended to conform to the <A href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1429.htm">
regular expression standardisation proposal</A>, which will appear in a
regular expression standardization proposal</A>, which will appear in a
future C++ standard technical report (and hopefully in a future version of the
standard).&nbsp; Currently there are some differences in how the regular
expression traits classes are defined, these will be fixed in a future release.</P>
@ -36,10 +35,10 @@
<P>Negated class escapes (\S, \D and \W) are not permitted inside character class
definitions ( [...] ).</P>
<P>The escape sequence \u matches any upper case character (the same as
[[:upper:]])&nbsp;rather than a unicode escape sequence; use \x{DDDD} for
unicode escape sequences.</P>
[[:upper:]])&nbsp;rather than a Unicode escape sequence; use \x{DDDD} for
Unicode escape sequences.</P>
<H3>Perl</H3>
<P>Almost all perl features are supported, except for:</P>
<P>Almost all Perl features are supported, except for:</P>
<P>\N{name}&nbsp; Use [[:name:]] instead.</P>
<P>\pP and \PP</P>
<P>(?imsx-imsx)</P>
@ -48,25 +47,23 @@
<P>(?{code})</P>
<P>(??{code})</P>
<P>(?(condition)yes-pattern) and (?(condition)yes-pattern|no-pattern)</P>
<P>These embarressments / limitations will be removed in due course, mainly
<P>These embarrassments / limitations will be removed in due course, mainly
dependent upon user demand.</P>
<H3>POSIX</H3>
<P>All the POSIX basic and extended regular expression features are supported,
except that:</P>
<P>No character collating names are recognised except those specified in the POSIX
<P>No character collating names are recognized except those specified in the POSIX
standard for the C locale, unless they are explicitly registered with the
traits class.</P>
<P>Character equivalence classes ( [[=a=]] etc) are probably buggy except on
Win32.&nbsp; Implimenting this feature requires knowledge of the format of the
Win32.&nbsp; Implementing this feature requires knowledge of the format of the
string sort keys produced by the system; if you need this, and the default
implementation doesn't work on your platfrom, then you will need to supply a
implementation doesn't work on your platform, then you will need to supply a
custom traits class.</P>
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
@ -78,3 +75,5 @@
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -23,7 +23,6 @@
</TABLE>
</P>
<HR>
<p></p>
<H3>Synopsis</H3>
<P>#include &lt;<A href="../../boost/regex.hpp">boost/regex.hpp</A>&gt;
</P>
@ -94,42 +93,42 @@ bool operator &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool operator == (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; lhs,
bool operator == (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 operator != (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; lhs,
bool operator != (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 operator &lt; (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; lhs,
bool operator &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 operator &gt; (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; lhs,
bool operator &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 operator &gt;= (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; lhs,
bool operator &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 operator &lt;= (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; lhs,
bool operator &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 operator == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; rhs);
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 operator != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; rhs);
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 operator &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; rhs);
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 operator &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; rhs);
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 operator &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; rhs);
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 operator &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; rhs);
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;::value_type, traits, Allocator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator == (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
@ -229,191 +228,189 @@ basic_ostream&lt;charT, traits&gt;&amp;
<PRE>bool matched</PRE>
<P>A Boolean value denoting whether this sub-expression participated in the match.</P>
<PRE>static difference_type length();</PRE>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>(matched ? 0 : distance(first, second))</CODE>.</P><PRE>operator basic_string&lt;value_type&gt;()const;</PRE>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>(matched ? basic_string&lt;value_type&gt;(first,
second) : basic_string&lt;value_type&gt;()).</P></CODE><PRE>basic_string&lt;value_type&gt; str()const;</PRE>
<B>
<P>
<P><B>
Effects: </B>returns <CODE>(matched ? basic_string&lt;value_type&gt;(first,
second) : basic_string&lt;value_type&gt;())</CODE>.</P><PRE>int compare(const sub_match&amp; s)const;</PRE>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>str().compare(s.str())</CODE>.</P><PRE>int compare(const basic_string&lt;value_type&gt;&amp; s)const;</PRE>
<B>
<P>
<P><B>
Effects: </B>returns <CODE>str().compare(s)</CODE>.</P><PRE>int compare(const value_type* s)const;</PRE>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>str().compare(s)</CODE>.</P>
<H4>
sub_match non-member operators</H4>
<PRE>template &lt;class BidirectionalIterator&gt;
bool operator == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);</PRE>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs.compare(rhs) == 0</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);</PRE>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs.compare(rhs) != 0</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs.compare(rhs) &lt; 0</CODE>.</P><PRE>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>
<B>
<P>
<P><B>
Effects: </B>returns <CODE>lhs.compare(rhs) &lt;= 0</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs.compare(rhs) &gt;= 0</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs.compare(rhs) &gt; 0</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs == rhs.str()</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs != rhs.str()</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs &lt; rhs.str()</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs &gt; rhs.str()</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs &gt;= rhs.str()</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs &lt;= rhs.str()</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs.str() == rhs</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs.str() != rhs</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs.str() &lt; rhs</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs.str() &gt; rhs</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs.str() &gt;= rhs</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs.str() &lt;= rhs</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs == rhs.str()</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs != rhs.str()</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs &lt; rhs.str()</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs &gt; rhs.str()</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs &gt;= rhs.str()</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs &lt;= rhs.str()</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs.str() == rhs</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs.str() != rhs</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs.str() &lt; rhs</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs.str() &gt; rhs</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs.str() &gt;= rhs</CODE>.</P><PRE>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>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>lhs.str() &lt;= rhs</CODE>.</P><PRE>template &lt;class charT, class traits, class BidirectionalIterator&gt;
basic_ostream&lt;charT, traits&gt;&amp;
operator &lt;&lt; (basic_ostream&lt;charT, traits&gt;&amp; os
const sub_match&lt;BidirectionalIterator&gt;&amp; m);</PRE>
<B>
<P>
<P> <B>
Effects: </B>returns <CODE>(os &lt;&lt; m.str())</CODE>.
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
@ -425,3 +422,5 @@ basic_ostream&lt;charT, traits&gt;&amp;
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -23,7 +23,6 @@
</TABLE>
</P>
<HR>
<p></p>
<P>This section covers the regular expression syntax used by this library, this is
a programmers guide, the actual syntax presented to your program's users will
depend upon the flags used during expression compilation.
@ -34,7 +33,7 @@
"}", "[", "]", "^", "$" and "\". These characters are literals when preceded by
a "\". A literal is a character that matches itself, or matches the result of
traits_type::translate(), where traits_type is the traits template parameter to
class reg_expression.</P>
class basic_regex.</P>
<H3>Wildcard
</H3>
<P>The dot character "." matches any single character except : when <I>match_not_dot_null</I>
@ -123,14 +122,14 @@
expression "abc".</P>
<H3>Independent sub-expressions</H3>
<P>"(?&gt;expression)" matches "expression" as an independent atom (the algorithm
will not backtrack into it if a failure occures later in the expression).</P>
will not backtrack into it if a failure occurs later in the expression).</P>
<H3>Alternatives
</H3>
<P>Alternatives occur when the expression can match either one sub-expression or
another, each alternative is separated by a "|", or a "\|" if the flag
regex_constants::bk_vbar is set, or by a newline character if the flag
regex_constants::newline_alt is set. Each alternative is the largest possible
previous sub-expression; this is the opposite behaviour from repetition
previous sub-expression; this is the opposite behavior from repetition
operators.
</P>
<P>Examples:
@ -167,7 +166,7 @@
when the default "C" locale is in effect. For example if the library is
compiled with the Win32 localization model, then [a-z] will match the ASCII
characters a-z, and also 'A', 'B' etc, but not 'Z' which collates just after
'z'. This locale specific behaviour is disabled by default (in perl mode), and
'z'. This locale specific behavior is disabled by default (in perl mode), and
forces ranges to collate according to ASCII character code.
</P>
<P>Character classes are denoted using the syntax "[:classname:]" within a set
@ -263,7 +262,7 @@
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">unicode</TD>
<TD vAlign="top" width="50%">Unicode</TD>
<TD vAlign="top" width="50%">Any character whose code is greater than 255, this
applies to the wide character traits classes only.</TD>
<TD>&nbsp;</TD>
@ -373,7 +372,7 @@
</P>
<H3>Buffer operators
</H3>
<P>The following operators are provide for compatibility with the GNU regular
<P>The following operators are provided for compatibility with the GNU regular
expression library, and Perl regular expressions:
</P>
<P>"\`" matches the start of a buffer.
@ -521,7 +520,7 @@
<TD vAlign="top" width="33%">0xXX
</TD>
<TD vAlign="top" width="33%">A hexadecimal character code, where XX is one or more
hexadecimal digits, optionally a unicode character.
hexadecimal digits, optionally a Unicode character.
</TD>
<TD>&nbsp;</TD>
</TR>
@ -667,9 +666,9 @@
<H3>What gets matched?
</H3>
<P>
When the expression is compiled as a perl-compatible regex then the matching
When the expression is compiled as a Perl-compatible regex then the matching
algorithms will perform a depth first search on the state machine and report
the first match found.
the first match found.</P>
<P>
When the expression is compiled as a POSIX-compatible regex then the matching
algorithms will match the first possible matching string, if more than one
@ -683,15 +682,11 @@
chosen is the one with the longest first sub-expression, if that is the same
for two or more matches, then the second sub-expression will be examined and so
on.
<P></P>
The following table examples illustrate the main differences between perl and
</P><P>
The following table examples illustrate the main differences between Perl and
POSIX regular expression matching rules:
<P></P>
</P>
<P>
<DIV align="center">
<P></P>
<P align="center">
<CENTER>
<TABLE id="Table5" cellSpacing="1" cellPadding="7" width="624" border="1">
<TBODY>
<TR>
@ -709,29 +704,27 @@
</TD>
</TR>
<TR>
<TD vAlign="top" width="25%"><CODE>
<P>
a|ab</CODE>
</P>
<TD vAlign="top" width="25%">
<P><CODE>a|ab</CODE></P>
</TD>
<TD vAlign="top" width="25%"><CODE>
<P>
<TD vAlign="top" width="25%">
<P><CODE>
xaby</CODE>
</P>
</TD>
<TD vAlign="top" width="25%"><CODE>
<P>
<TD vAlign="top" width="25%">
<P><CODE>
"ab"</CODE></P></TD>
<TD vAlign="top" width="25%"><CODE>
<P>
<TD vAlign="top" width="25%">
<P><CODE>
"a"</CODE></P></TD>
</TR>
<TR>
<TD vAlign="top" width="25%"><CODE>
<P>
<TD vAlign="top" width="25%">
<P><CODE>
.*([[:alnum:]]+).*</CODE></P></TD>
<TD vAlign="top" width="25%"><CODE>
<P>
<TD vAlign="top" width="25%">
<P><CODE>
" abc def xyz "</CODE></P></TD>
<TD vAlign="top" width="25%">
<P>$0 = " abc def xyz "<BR>
@ -743,33 +736,28 @@
</TD>
</TR>
<TR>
<TD vAlign="top" width="25%"><CODE>
<P>
<TD vAlign="top" width="25%">
<P><CODE>
.*(a|xayy)</CODE></P></TD>
<TD vAlign="top" width="25%"><CODE>
<P>
<TD vAlign="top" width="25%">
<P><CODE>
zzxayyzz</CODE></P></TD>
<TD vAlign="top" width="25%"><CODE>
<P>
<TD vAlign="top" width="25%">
<P><CODE>
"zzxayy"</CODE></P></TD>
<TD vAlign="top" width="25%"><CODE>
<P>"zzxa"</P>
<P></P>
</CODE>
<TD vAlign="top" width="25%">
<P><CODE>"zzxa"</CODE></P>
</TD>
</TR>
</TBODY></CODE></TD></TR></TABLE></CENTER>
<P></P>
</DIV>
<P>These differences between perl matching rules, and POSIX matching rules, mean
</TBODY></CODE></TD></TR></TABLE>
<P>These differences between Perl matching rules, and POSIX matching rules, mean
that these two regular expression syntaxes differ not only in the features
offered, but also in the form that the state machine takes and/or the
algorithms used to traverse the state machine.
algorithms used to traverse the state machine.</p>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
@ -781,3 +769,5 @@
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -23,7 +23,6 @@
</TABLE>
</P>
<HR>
<p></p>
<H3>Synopsis</H3>
<P>Type syntax_option type is an implementation defined bitmask type that controls
how a regular expression string is to be interpreted.&nbsp; For convenience
@ -83,7 +82,7 @@ static const syntax_option_type perl;<BR>// these are boost.regex specific:<BR>s
normal semantics: that is the same as that given in the ECMA-262, ECMAScript
Language Specification, Chapter 15 part 10, RegExp (Regular Expression) Objects
(FWD.1).</P>
<P>boost.regex also recognises most perl-compatible extensions in this mode.</P>
<P>boost.regex also recognizes most perl-compatible extensions in this mode.</P>
</TD>
</TR>
<TR>
@ -229,7 +228,6 @@ static const syntax_option_type perl;<BR>// these are boost.regex specific:<BR>s
</TR>
</TABLE>
</P>
<P>
<P>The following constants are specific to this particular regular expression
implementation and do not appear in the <A href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1429.htm">
regular expression standardization proposal</A>:</P>
@ -279,7 +277,7 @@ static const syntax_option_type perl;<BR>// these are boost.regex specific:<BR>s
<TD vAlign="top" width="45%">regbase:: bk_parens</TD>
<TD vAlign="top" width="45%">When this bit is set then "\(" and "\)" are used to
group sub-expressions and "(" and ")" are ordinary characters, this is the
opposite of default behaviour.</TD>
opposite of default behavior.</TD>
</TR>
<TR>
<TD vAlign="top" width="45%">regbase:: bk_refs</TD>
@ -290,13 +288,13 @@ static const syntax_option_type perl;<BR>// these are boost.regex specific:<BR>s
<TD vAlign="top" width="45%">regbase:: bk_vbar</TD>
<TD vAlign="top" width="45%">When this bit is set then "\|" represents the
alternation operator and "|" is an ordinary character. This is the opposite of
default behaviour.</TD>
default behavior.</TD>
</TR>
<TR>
<TD vAlign="top" width="45%">regbase:: use_except</TD>
<TD vAlign="top" width="45%">When this bit is set then a <A href="#bad_expression">bad_expression</A>
exception will be thrown on error.&nbsp; Use of this flag is deprecated -
reg_expression will always throw on error.</TD>
basic_regex will always throw on error.</TD>
</TR>
<TR>
<TD vAlign="top" width="45%">regbase:: failbit</TD>
@ -316,12 +314,10 @@ static const syntax_option_type perl;<BR>// these are boost.regex specific:<BR>s
</TR>
</TABLE>
</P>
<P>
<HR>
</P>
<P>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></P>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
@ -332,3 +328,5 @@ static const syntax_option_type perl;<BR>// these are boost.regex specific:<BR>s
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -23,39 +23,40 @@
</TABLE>
</P>
<HR>
<p></p>
<P>Class basic_regex&lt;&gt; and its typedefs regex and wregex are thread safe, in
that compiled regular expressions can safely be shared between threads. The
matching algorithms regex_match, regex_search, regex_grep, regex_format and
regex_merge are all re-entrant and thread safe. Class match_results is now
thread safe, in that the results of a match can be safely copied from one
thread to another (for example one thread may find matches and push
<P>Class <A href="basic_regex.html">basic_regex</A>&lt;&gt; and its typedefs regex
and wregex are thread safe, in that compiled regular expressions can safely be
shared between threads. The matching algorithms <A href="regex_match.html">regex_match</A>,
<A href="regex_search.html">regex_search</A>, <A href="regex_grep.html">regex_grep</A>,
<A href="regex_format.html">regex_format</A> and <A href="regex_merge.html">regex_merge</A>
are all re-entrant and thread safe. Class <A href="match_results.html">match_results</A>
is now thread safe, in that the results of a match can be safely copied from
one thread to another (for example one thread may find matches and push
match_results instances onto a queue, while another thread pops them off the
other end), otherwise use a separate instance of match_results per thread.
other end), otherwise use a separate instance of <A href="match_results.html">match_results</A>
per thread.
</P>
<P>The POSIX API functions are all re-entrant and thread safe, regular expressions
compiled with <I>regcomp</I> can also be shared between threads.
<P>The <A href="posix_api.html">POSIX API functions</A> are all re-entrant and
thread safe, regular expressions compiled with <I>regcomp</I> can also be
shared between threads.
</P>
<P>The class RegEx is only thread safe if each thread gets its own RegEx instance
(apartment threading) - this is a consequence of RegEx handling both compiling
and matching regular expressions.
<P>The class<A href="regex.html"> RegEx</A> is only thread safe if each thread
gets its own RegEx instance (apartment threading) - this is a consequence of
RegEx handling both compiling and matching regular expressions.
</P>
<P>Finally note that changing the global locale invalidates all compiled regular
expressions, therefore calling <I>set_locale</I> from one thread while another
uses regular expressions <I>will</I> produce unpredictable results.
</P>
<P>
There is also a requirement that there is only one thread executing prior to
the start of main().
<P>
<HR>
<P></P>
There is also a requirement that there is only one thread executing prior to
the start of main().</P>
<HR>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
17 May 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
@ -64,3 +65,4 @@
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

705
doc/vc71-performance.html Normal file
View File

@ -0,0 +1,705 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>Regular Expression Performance Comparison (Visual Studio.NET 2003)</title>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<META content="C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\html.dot" name="Template">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
</head>
<body bgcolor="#ffffff" link="#0000ff" vlink="#800080">
<h2>Regular Expression Performance Comparison</h2>
<p>The following tables provide comparisons between the following regular
expression libraries:</p>
<p><a href="http://research.microsoft.com/projects/greta"> GRETA</a>.</p>
<p><a href="http://www.boost.org/">The Boost regex library</a>.</p>
<p><a href="http://arglist.com/regex/">Henry Spencer's regular expression library</a>
- this is provided for comparison as a typical non-backtracking implementation.</p>
<p>Philip Hazel's <a href="http://www.pcre.org">PCRE</a> library.</p>
<h3>Details</h3>
<p>Machine: Intel Pentium 4 2.8GHz PC.</p>
<p>Compiler: Microsoft Visual C++ version 7.1.</p>
<p>C++ Standard Library: Dinkumware standard library version 313.</p>
<p>OS: Win32.</p>
<p>Boost version: 1.31.0.</p>
<p>PCRE version: 3.9.</p>
<p>As ever care should be taken in interpreting the results, only sensible regular
expressions (rather than pathological cases) are given, most are taken from the
Boost regex examples, or from the <a href="http://www.regxlib.com/">Library of
Regular Expressions</a>. In addition, some variation in the relative
performance of these libraries can be expected on other machines - as memory
access and processor caching effects can be quite large for most finite state
machine algorithms.&nbsp; In each case the first figure given is the relative
time taken (so a value of 1.0 is as good as it gets), while the second figure
is the actual time taken.</p>
<h3>Averages</h3>
<p>The following are the average relative scores for all the tests: the perfect
regular expression library&nbsp;would score 1, in practice anything less than 2
is pretty good.</p>
<table border="1" cellspacing="1">
<tr>
<td><strong>GRETA</strong></td>
<td><strong>GRETA<br>
(non-recursive mode)</strong></td>
<td><strong>Boost</strong></td>
<td><strong>Boost + C++ locale</strong></td>
<td><strong>POSIX</strong></td>
<td><strong>PCRE</strong></td>
</tr>
<tr>
<td>6.90669</td>
<td>23.751</td>
<td>1.62553</td>
<td>1.38213</td>
<td>110.973</td>
<td>1.69371</td>
</tr>
</table>
<br>
<br>
<h3>Comparison 1: Long Search</h3>
<p>For each of the following regular expressions the time taken to find all
occurrences of the expression within a long English language text was measured
(<a href="ftp://ibiblio.org/pub/docs/books/gutenberg/etext02/mtent12.zip">mtent12.txt</a>
from <a href="http://promo.net/pg/">Project Gutenberg</a>, 19Mb).&nbsp;</p>
<table border="1" cellspacing="1">
<tr>
<td><strong>Expression</strong></td>
<td><strong>GRETA</strong></td>
<td><strong>GRETA<br>
(non-recursive mode)</strong></td>
<td><strong>Boost</strong></td>
<td><strong>Boost + C++ locale</strong></td>
<td><strong>POSIX</strong></td>
<td><strong>PCRE</strong></td>
</tr>
<tr>
<td><code>Twain</code></td>
<td>19.7<br>
(0.541s)</td>
<td>85.5<br>
(2.35s)</td>
<td>3.09<br>
(0.0851s)</td>
<td>3.09<br>
(0.0851s)</td>
<td>131<br>
(3.6s)</td>
<td><font color="#008000">1<br>
(0.0275s)</font></td>
</tr>
<tr>
<td><code>Huck[[:alpha:]]+</code></td>
<td>11<br>
(0.55s)</td>
<td>93.4<br>
(4.68s)</td>
<td>3.4<br>
(0.17s)</td>
<td>3.35<br>
(0.168s)</td>
<td>124<br>
(6.19s)</td>
<td><font color="#008000">1<br>
(0.0501s)</font></td>
</tr>
<tr>
<td><code>[[:alpha:]]+ing</code></td>
<td>11.3<br>
(6.82s)</td>
<td>21.3<br>
(12.8s)</td>
<td>1.83<br>
(1.1s)</td>
<td><font color="#008000">1<br>
(0.601s)</font></td>
<td>6.47<br>
(3.89s)</td>
<td>4.75<br>
(2.85s)</td>
</tr>
<tr>
<td><code>^[^ ]*?Twain</code></td>
<td>5.75<br>
(1.15s)</td>
<td>17.1<br>
(3.43s)</td>
<td><font color="#008000">1<br>
(0.2s)</font></td>
<td>1.3<br>
(0.26s)</td>
<td>NA</td>
<td>3.8<br>
(0.761s)</td>
</tr>
<tr>
<td><code>Tom|Sawyer|Huckleberry|Finn</code></td>
<td>28.5<br>
(3.1s)</td>
<td>77.2<br>
(8.4s)</td>
<td>2.3<br>
(0.251s)</td>
<td><font color="#008000">1<br>
(0.109s)</font></td>
<td>191<br>
(20.8s)</td>
<td>1.77<br>
(0.193s)</td>
</tr>
<tr>
<td><code> (Tom|Sawyer|Huckleberry|Finn).{0,30}river|river.{0,30}(Tom|Sawyer|Huckleberry|Finn)</code></td>
<td>16.2<br>
(4.14s)</td>
<td>49<br>
(12.5s)</td>
<td>1.65<br>
(0.42s)</td>
<td><font color="#008000">1<br>
(0.255s)</font></td>
<td>NA</td>
<td>2.43<br>
(0.62s)</td>
</tr>
</table>
<br>
<br>
<h3>Comparison 2: Medium Sized Search</h3>
<p>For each of the following regular expressions the time taken to find all
occurrences of the expression within a medium sized English language text was
measured (the first 50K from mtent12.txt).&nbsp;</p>
<table border="1" cellspacing="1">
<tr>
<td><strong>Expression</strong></td>
<td><strong>GRETA</strong></td>
<td><strong>GRETA<br>
(non-recursive mode)</strong></td>
<td><strong>Boost</strong></td>
<td><strong>Boost + C++ locale</strong></td>
<td><strong>POSIX</strong></td>
<td><strong>PCRE</strong></td>
</tr>
<tr>
<td><code>Twain</code></td>
<td>9.49<br>
(0.00274s)</td>
<td>40.7<br>
(0.0117s)</td>
<td>1.54<br>
(0.000445s)</td>
<td>1.56<br>
(0.00045s)</td>
<td>13.5<br>
(0.00391s)</td>
<td><font color="#008000">1<br>
(0.000289s)</font></td>
</tr>
<tr>
<td><code>Huck[[:alpha:]]+</code></td>
<td>14.3<br>
(0.0027s)</td>
<td>62.3<br>
(0.0117s)</td>
<td>2.26<br>
(0.000425s)</td>
<td>2.29<br>
(0.000431s)</td>
<td>1.27<br>
(0.000239s)</td>
<td><font color="#008000">1<br>
(0.000188s)</font></td>
</tr>
<tr>
<td><code>[[:alpha:]]+ing</code></td>
<td>7.34<br>
(0.0178s)</td>
<td>13.7<br>
(0.0331s)</td>
<td><font color="#008000">1<br>
(0.00243s)</font></td>
<td><font color="#008000">1.02<br>
(0.00246s)</font></td>
<td>7.36<br>
(0.0178s)</td>
<td>5.87<br>
(0.0142s)</td>
</tr>
<tr>
<td><code>^[^ ]*?Twain</code></td>
<td>8.34<br>
(0.00579s)</td>
<td>24.8<br>
(0.0172s)</td>
<td>1.52<br>
(0.00105s)</td>
<td><font color="#008000">1<br>
(0.000694s)</font></td>
<td>NA</td>
<td>2.81<br>
(0.00195s)</td>
</tr>
<tr>
<td><code>Tom|Sawyer|Huckleberry|Finn</code></td>
<td>12.9<br>
(0.00781s)</td>
<td>35.1<br>
(0.0213s)</td>
<td>1.67<br>
(0.00102s)</td>
<td><font color="#008000">1<br>
(0.000606s)</font></td>
<td>81.5<br>
(0.0494s)</td>
<td>1.94<br>
(0.00117s)</td>
</tr>
<tr>
<td><code> (Tom|Sawyer|Huckleberry|Finn).{0,30}river|river.{0,30}(Tom|Sawyer|Huckleberry|Finn)</code></td>
<td>15.6<br>
(0.0106s)</td>
<td>46.6<br>
(0.0319s)</td>
<td>2.72<br>
(0.00186s)</td>
<td><font color="#008000">1<br>
(0.000684s)</font></td>
<td>311<br>
(0.213s)</td>
<td>1.72<br>
(0.00117s)</td>
</tr>
</table>
<br>
<br>
<h3>Comparison 3:&nbsp;C++ Code&nbsp;Search</h3>
<p>For each of the following regular expressions the time taken to find all
occurrences of the expression within the C++ source file <a href="../../../boost/crc.hpp">
boost/crc.hpp</a>&nbsp;was measured.&nbsp;</p>
<table border="1" cellspacing="1">
<tr>
<td><strong>Expression</strong></td>
<td><strong>GRETA</strong></td>
<td><strong>GRETA<br>
(non-recursive mode)</strong></td>
<td><strong>Boost</strong></td>
<td><strong>Boost + C++ locale</strong></td>
<td><strong>POSIX</strong></td>
<td><strong>PCRE</strong></td>
</tr>
<tr>
<td><code> ^(template[[:space:]]*&lt;[^;:{]+&gt;[[:space:]]*)?(class|struct)[[:space:]]*(\&lt;\w+\&gt;([
]*\([^)]*\))?[[:space:]]*)*(\&lt;\w*\&gt;)[[:space:]]*(&lt;[^;:{]+&gt;[[:space:]]*)?(\{|:[^;\{()]*\{)</code></td>
<td>8.88<br>
(0.000792s)</td>
<td>46.4<br>
(0.00414s)</td>
<td>1.19<br>
(0.000106s)</td>
<td><font color="#008000">1<br>
(8.92e-005s)</font></td>
<td>688<br>
(0.0614s)</td>
<td>3.23<br>
(0.000288s)</td>
</tr>
<tr>
<td><code>(^[
]*#(?:[^\\\n]|\\[^\n_[:punct:][:alnum:]]*[\n[:punct:][:word:]])*)|(//[^\n]*|/\*.*?\*/)|\&lt;([+-]?(?:(?:0x[[:xdigit:]]+)|(?:(?:[[:digit:]]*\.)?[[:digit:]]+(?:[eE][+-]?[[:digit:]]+)?))u?(?:(?:int(?:8|16|32|64))|L)?)\&gt;|('(?:[^\\']|\\.)*'|"(?:[^\\"]|\\.)*")|\&lt;(__asm|__cdecl|__declspec|__export|__far16|__fastcall|__fortran|__import|__pascal|__rtti|__stdcall|_asm|_cdecl|__except|_export|_far16|_fastcall|__finally|_fortran|_import|_pascal|_stdcall|__thread|__try|asm|auto|bool|break|case|catch|cdecl|char|class|const|const_cast|continue|default|delete|do|double|dynamic_cast|else|enum|explicit|extern|false|float|for|friend|goto|if|inline|int|long|mutable|namespace|new|operator|pascal|private|protected|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_cast|struct|switch|template|this|throw|true|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while)\&gt;</code></td>
<td><font color="#008000">1<br>
(0.00571s)</font></td>
<td>5.31<br>
(0.0303s)</td>
<td>2.47<br>
(0.0141s)</td>
<td>1.92<br>
(0.011s)</td>
<td>NA</td>
<td>3.29<br>
(0.0188s)</td>
</tr>
<tr>
<td><code>^[ ]*#[ ]*include[ ]+("[^"]+"|&lt;[^&gt;]+&gt;)</code></td>
<td>5.78<br>
(0.00172s)</td>
<td>26.3<br>
(0.00783s)</td>
<td>1.12<br>
(0.000333s)</td>
<td><font color="#008000">1<br>
(0.000298s)</font></td>
<td>128<br>
(0.0382s)</td>
<td>1.74<br>
(0.000518s)</td>
</tr>
<tr>
<td><code>^[ ]*#[ ]*include[ ]+("boost/[^"]+"|&lt;boost/[^&gt;]+&gt;)</code></td>
<td>10.2<br>
(0.00305s)</td>
<td>28.4<br>
(0.00845s)</td>
<td>1.12<br>
(0.000333s)</td>
<td><font color="#008000">1<br>
(0.000298s)</font></td>
<td>155<br>
(0.0463s)</td>
<td>1.74<br>
(0.000519s)</td>
</tr>
</table>
<br>
<h3></h3>
<H3>Comparison 4: HTML Document Search
</H3>
<p>For each of the following regular expressions the time taken to find all
occurrences of the expression within the html file <a href="../../libraries.htm">libs/libraries.htm</a>
was measured.&nbsp;</p>
<table border="1" cellspacing="1">
<tr>
<td><strong>Expression</strong></td>
<td><strong>GRETA</strong></td>
<td><strong>GRETA<br>
(non-recursive mode)</strong></td>
<td><strong>Boost</strong></td>
<td><strong>Boost + C++ locale</strong></td>
<td><strong>POSIX</strong></td>
<td><strong>PCRE</strong></td>
</tr>
<tr>
<td><code>beman|john|dave</code></td>
<td>11<br>
(0.00297s)</td>
<td>34.3<br>
(0.00922s)</td>
<td>1.78<br>
(0.000479s)</td>
<td><font color="#008000">1<br>
(0.000269s)</font></td>
<td>55.2<br>
(0.0149s)</td>
<td>1.85<br>
(0.000499s)</td>
</tr>
<tr>
<td><code>&lt;p&gt;.*?&lt;/p&gt;</code></td>
<td>5.38<br>
(0.00145s)</td>
<td>21.8<br>
(0.00587s)</td>
<td><font color="#008000">1.02<br>
(0.000274s)</font></td>
<td><font color="#008000">1<br>
(0.000269s)</font></td>
<td>NA</td>
<td><font color="#008000">1.05<br>
(0.000283s)</font></td>
</tr>
<tr>
<td><code> &lt;a[^&gt;]+href=("[^"]*"|[^[:space:]]+)[^&gt;]*&gt;</code></td>
<td>4.51<br>
(0.00207s)</td>
<td>12.6<br>
(0.00579s)</td>
<td>1.34<br>
(0.000616s)</td>
<td><font color="#008000">1<br>
(0.000459s)</font></td>
<td>343<br>
(0.158s)</td>
<td><font color="#008000">1.09<br>
(0.000499s)</font></td>
</tr>
<tr>
<td><code> &lt;h[12345678][^&gt;]*&gt;.*?&lt;/h[12345678]&gt;</code></td>
<td>7.39<br>
(0.00143s)</td>
<td>29.6<br>
(0.00571s)</td>
<td>1.87<br>
(0.000362s)</td>
<td><font color="#008000">1<br>
(0.000193s)</font></td>
<td>NA</td>
<td>1.27<br>
(0.000245s)</td>
</tr>
<tr>
<td><code> &lt;img[^&gt;]+src=("[^"]*"|[^[:space:]]+)[^&gt;]*&gt;</code></td>
<td>6.73<br>
(0.00145s)</td>
<td>27.3<br>
(0.00587s)</td>
<td>1.2<br>
(0.000259s)</td>
<td>1.32<br>
(0.000283s)</td>
<td>148<br>
(0.0319s)</td>
<td><font color="#008000">1<br>
(0.000215s)</font></td>
</tr>
<tr>
<td><code> &lt;font[^&gt;]+face=("[^"]*"|[^[:space:]]+)[^&gt;]*&gt;.*?&lt;/font&gt;</code></td>
<td>6.93<br>
(0.00153s)</td>
<td>27<br>
(0.00595s)</td>
<td>1.22<br>
(0.000269s)</td>
<td>1.31<br>
(0.000289s)</td>
<td>NA</td>
<td><font color="#008000">1<br>
(0.00022s)</font></td>
</tr>
</table>
<br>
<br>
<h3>Comparison 3: Simple Matches</h3>
<p>For each of the following regular expressions the time taken to match against
the text indicated was measured.&nbsp;</p>
<table border="1" cellspacing="1">
<tr>
<td><strong>Expression</strong></td>
<td><strong>Text</strong></td>
<td><strong>GRETA</strong></td>
<td><strong>GRETA<br>
(non-recursive mode)</strong></td>
<td><strong>Boost</strong></td>
<td><strong>Boost + C++ locale</strong></td>
<td><strong>POSIX</strong></td>
<td><strong>PCRE</strong></td>
</tr>
<tr>
<td><code>abc</code></td>
<td>abc</td>
<td>1.31<br>
(2.2e-007s)</td>
<td>1.94<br>
(3.25e-007s)</td>
<td>1.26<br>
(2.1e-007s)</td>
<td>1.24<br>
(2.08e-007s)</td>
<td>3.03<br>
(5.06e-007s)</td>
<td><font color="#008000">1<br>
(1.67e-007s)</font></td>
</tr>
<tr>
<td><code>^([0-9]+)(\-| |$)(.*)$</code></td>
<td>100- this is a line of ftp response which contains a message string</td>
<td>1.52<br>
(6.88e-007s)</td>
<td>2.28<br>
(1.03e-006s)</td>
<td>1.5<br>
(6.78e-007s)</td>
<td>1.5<br>
(6.78e-007s)</td>
<td>329<br>
(0.000149s)</td>
<td><font color="#008000">1<br>
(4.53e-007s)</font></td>
</tr>
<tr>
<td><code>([[:digit:]]{4}[- ]){3}[[:digit:]]{3,4}</code></td>
<td>1234-5678-1234-456</td>
<td>2.04<br>
(1.03e-006s)</td>
<td>2.83<br>
(1.43e-006s)</td>
<td>2.12<br>
(1.07e-006s)</td>
<td>2.04<br>
(1.03e-006s)</td>
<td>30.8<br>
(1.56e-005s)</td>
<td><font color="#008000">1<br>
(5.05e-007s)</font></td>
</tr>
<tr>
<td><code> ^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$</code></td>
<td>john_maddock@compuserve.com</td>
<td>1.48<br>
(1.78e-006s)</td>
<td>2.1<br>
(2.52e-006s)</td>
<td>1.35<br>
(1.62e-006s)</td>
<td>1.32<br>
(1.59e-006s)</td>
<td>165<br>
(0.000198s)</td>
<td><font color="#008000">1<br>
(1.2e-006s)</font></td>
</tr>
<tr>
<td><code> ^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$</code></td>
<td>foo12@foo.edu</td>
<td>1.28<br>
(1.41e-006s)</td>
<td>1.9<br>
(2.1e-006s)</td>
<td>1.42<br>
(1.57e-006s)</td>
<td>1.38<br>
(1.53e-006s)</td>
<td>107<br>
(0.000119s)</td>
<td><font color="#008000">1<br>
(1.11e-006s)</font></td>
</tr>
<tr>
<td><code> ^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$</code></td>
<td>bob.smith@foo.tv</td>
<td>1.29<br>
(1.43e-006s)</td>
<td>1.9<br>
(2.1e-006s)</td>
<td>1.42<br>
(1.57e-006s)</td>
<td>1.38<br>
(1.53e-006s)</td>
<td>119<br>
(0.000132s)</td>
<td><font color="#008000">1<br>
(1.11e-006s)</font></td>
</tr>
<tr>
<td><code>^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$</code></td>
<td>EH10 2QQ</td>
<td>1.26<br>
(4.63e-007s)</td>
<td>1.77<br>
(6.49e-007s)</td>
<td>1.3<br>
(4.77e-007s)</td>
<td>1.2<br>
(4.4e-007s)</td>
<td>9.15<br>
(3.36e-006s)</td>
<td><font color="#008000">1<br>
(3.68e-007s)</font></td>
</tr>
<tr>
<td><code>^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$</code></td>
<td>G1 1AA</td>
<td><font color="#008000">1.06<br>
(4.73e-007s)</font></td>
<td>1.59<br>
(7.07e-007s)</td>
<td><font color="#008000">1.05<br>
(4.68e-007s)</font></td>
<td><font color="#008000">1<br>
(4.44e-007s)</font></td>
<td>12.9<br>
(5.73e-006s)</td>
<td>1.63<br>
(7.26e-007s)</td>
</tr>
<tr>
<td><code>^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$</code></td>
<td>SW1 1ZZ</td>
<td>1.26<br>
(9.17e-007s)</td>
<td>1.84<br>
(1.34e-006s)</td>
<td>1.28<br>
(9.26e-007s)</td>
<td>1.21<br>
(8.78e-007s)</td>
<td>8.42<br>
(6.11e-006s)</td>
<td><font color="#008000">1<br>
(7.26e-007s)</font></td>
</tr>
<tr>
<td><code> ^[[:digit:]]{1,2}/[[:digit:]]{1,2}/[[:digit:]]{4}$</code></td>
<td>4/1/2001</td>
<td>1.57<br>
(9.73e-007s)</td>
<td>2.28<br>
(1.41e-006s)</td>
<td>1.25<br>
(7.73e-007s)</td>
<td>1.26<br>
(7.83e-007s)</td>
<td>11.2<br>
(6.95e-006s)</td>
<td><font color="#008000">1<br>
(6.21e-007s)</font></td>
</tr>
<tr>
<td><code> ^[[:digit:]]{1,2}/[[:digit:]]{1,2}/[[:digit:]]{4}$</code></td>
<td>12/12/2001</td>
<td>1.52<br>
(9.56e-007s)</td>
<td>2.06<br>
(1.3e-006s)</td>
<td>1.29<br>
(8.12e-007s)</td>
<td>1.24<br>
(7.83e-007s)</td>
<td>12.4<br>
(7.8e-006s)</td>
<td><font color="#008000">1<br>
(6.3e-007s)</font></td>
</tr>
<tr>
<td><code>^[-+]?[[:digit:]]*\.?[[:digit:]]*$</code></td>
<td>123</td>
<td>2.11<br>
(7.35e-007s)</td>
<td>3.18<br>
(1.11e-006s)</td>
<td>2.5<br>
(8.7e-007s)</td>
<td>2.44<br>
(8.5e-007s)</td>
<td>5.26<br>
(1.83e-006s)</td>
<td><font color="#008000">1<br>
(3.49e-007s)</font></td>
</tr>
<tr>
<td><code>^[-+]?[[:digit:]]*\.?[[:digit:]]*$</code></td>
<td>+3.14159</td>
<td>1.31<br>
(4.96e-007s)</td>
<td>1.92<br>
(7.26e-007s)</td>
<td>1.26<br>
(4.77e-007s)</td>
<td>1.2<br>
(4.53e-007s)</td>
<td>9.71<br>
(3.66e-006s)</td>
<td><font color="#008000">1<br>
(3.77e-007s)</font></td>
</tr>
<tr>
<td><code>^[-+]?[[:digit:]]*\.?[[:digit:]]*$</code></td>
<td>-3.14159</td>
<td>1.32<br>
(4.97e-007s)</td>
<td>1.92<br>
(7.26e-007s)</td>
<td>1.24<br>
(4.67e-007s)</td>
<td>1.2<br>
(4.53e-007s)</td>
<td>9.7<br>
(3.66e-006s)</td>
<td><font color="#008000">1<br>
(3.78e-007s)</font></td>
</tr>
</table>
<br>
<br>
<hr>
<p>Copyright John Maddock April 2003, all rights reserved.</p>
</body>
</html>

9
index.html Normal file
View File

@ -0,0 +1,9 @@
<html>
<head>
<meta http-equiv="refresh" content="0; URL=doc/index.html">
</head>
<body>
Automatic redirection failed, please go to <A href="doc/index.html">doc/index.html</A>.
</body>
</html>

View File

@ -1,671 +0,0 @@
<html>
<head>
<title>Regular Expression Performance Comparison</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<meta name="Template" content="C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\html.dot">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
</head>
<body bgcolor="#ffffff" link="#0000ff" vlink="#800080">
<h2>Regular Expression Performance Comparison</h2>
<p>The Boost and GRETA regular expression libraries have slightly different
interfaces, and it has been suggested that GRETA's interface allows for a more
efficient implementation. The following tables provide comparisons between:</p>
<p><a href="http://research.microsoft.com/projects/greta">GRETA</a>.</p>
<p><a href="http://www.boost.org/">The Boost regex library</a>.</p>
<p><a href="http://arglist.com/regex/">Henry Spencer's regular expression library</a>
- this is provided for comparison as a typical non-backtracking implementation.</p>
<p>
Times were obtained on a 2.8GHz Pentium&nbsp;4 PC running Windows XP, and the
code was compiled with Visual C++ 7.1 with all optimisations turned on. As ever
care should be taken in interpreting the results, only sensible regular
expressions (rather than pathological cases) are given, most are taken from the
Boost regex examples, or from the <a href="http://www.regxlib.com/">Library of
Regular Expressions</a>. In addition, some variation in the relative
performance of these libraries can be expected on other machines - as memory
access and processor caching effects can be quite large for most finite state
machine algorithms.</p>
<h3>Comparison 1: Long Search</h3>
<p>For each of the following regular expressions the time taken to find all
occurrences of the expression within a long English language text was measured
(<a href="ftp://ibiblio.org/pub/docs/books/gutenberg/etext02/mtent12.zip">mtent12.txt</a>
from <a href="http://promo.net/pg/">Project Gutenberg</a>, 19Mb).&nbsp;</p>
<P><table border="1" cellspacing="1">
<tr>
<td><strong>Expression</strong></td>
<td><strong>GRETA</strong></td>
<td><strong>GRETA<BR>
(non-recursive mode)</strong></td>
<td><strong>Boost</strong></td>
<td><strong>Boost + C++ locale</strong></td>
<td><strong>POSIX</strong></td>
<td><strong>PCRE</strong></td>
</tr>
<tr>
<td><code>Twain</code></td>
<td>9.29<BR>
(0.00309s)</td>
<td>32.9<BR>
(0.011s)</td>
<td>1.34<BR>
(0.000445s)</td>
<td>1.37<BR>
(0.000455s)</td>
<td>6.23<BR>
(0.00207s)</td>
<td><font color="#008000">1<BR>
(0.000333s)</font></td>
</tr>
<tr>
<td><code>Huck[[:alpha:]]+</code></td>
<td>12.9<BR>
(0.00309s)</td>
<td>44.4<BR>
(0.0106s)</td>
<td>1.79<BR>
(0.00043s)</td>
<td>1.82<BR>
(0.000436s)</td>
<td><font color="#008000">1<BR>
(0.00024s)</font></td>
<td><font color="#008000">1.06<BR>
(0.000254s)</font></td>
</tr>
<tr>
<td><code>[[:alpha:]]+ing</code></td>
<td>7.6<BR>
(0.0178s)</td>
<td>15.2<BR>
(0.0357s)</td>
<td><font color="#008000">1<BR>
(0.00235s)</font></td>
<td><font color="#008000">0.867<BR>
(0.00204s)</font></td>
<td>4.26<BR>
(0.01s)</td>
<td>6<BR>
(0.0141s)</td>
</tr>
<tr>
<td><code>^[^ ]*?Twain</code></td>
<td>5.92<BR>
(0.00626s)</td>
<td>16.3<BR>
(0.0172s)</td>
<td><font color="#008000">1<BR>
(0.00106s)</font></td>
<td><font color="#008000">0.666<BR>
(0.000704s)</font></td>
<td>NA</td>
<td>2.04<BR>
(0.00215s)</td>
</tr>
<tr>
<td><code>Tom|Sawyer|Huckleberry|Finn</code></td>
<td>8<BR>
(0.00828s)</td>
<td>20<BR>
(0.0207s)</td>
<td><font color="#008000">1<BR>
(0.00104s)</font></td>
<td><font color="#008000">0.585<BR>
(0.000605s)</font></td>
<td>42.3<BR>
(0.0438s)</td>
<td>1.12<BR>
(0.00115s)</td>
</tr>
<tr>
<td><code>(Tom|Sawyer|Huckleberry|Finn).{0,30}river|river.{0,30}(Tom|Sawyer|Huckleberry|Finn)</code></td>
<td>6.42<BR>
(0.012s)</td>
<td>16.3<BR>
(0.0307s)</td>
<td><font color="#008000">1<BR>
(0.00188s)</font></td>
<td><font color="#008000">0.719<BR>
(0.00135s)</font></td>
<td>NA</td>
<td>1.21<BR>
(0.00227s)</td>
</tr>
</table>
</P>
<h3>Comparison 2: Medium Sized Search</h3>
<p>For each of the following regular expressions the time taken to find all
occurrences of the expression within a medium sized English language text was
measured (the first 50K from mtent12.txt).&nbsp;</p>
<P><table border="1" cellspacing="1">
<tr>
<td><strong>Expression</strong></td>
<td><strong>GRETA</strong></td>
<td><strong>GRETA<BR>
(non-recursive mode)</strong></td>
<td><strong>Boost</strong></td>
<td><strong>Boost + C++ locale</strong></td>
<td><strong>POSIX</strong></td>
<td><strong>PCRE</strong></td>
</tr>
<tr>
<td><code>Twain</code></td>
<td>9.29<BR>
(0.00309s)</td>
<td>32.5<BR>
(0.0108s)</td>
<td>1.34<BR>
(0.000445s)</td>
<td>1.37<BR>
(0.000455s)</td>
<td>6.24<BR>
(0.00207s)</td>
<td><font color="#008000">1<BR>
(0.000333s)</font></td>
</tr>
<tr>
<td><code>Huck[[:alpha:]]+</code></td>
<td>12.9<BR>
(0.00309s)</td>
<td>47<BR>
(0.0113s)</td>
<td>1.77<BR>
(0.000425s)</td>
<td>1.84<BR>
(0.00044s)</td>
<td><font color="#008000">1<BR>
(0.00024s)</font></td>
<td><font color="#008000">1.04<BR>
(0.00025s)</font></td>
</tr>
<tr>
<td><code>[[:alpha:]]+ing</code></td>
<td>7.61<BR>
(0.0178s)</td>
<td>15.2<BR>
(0.0356s)</td>
<td><font color="#008000">1<BR>
(0.00234s)</font></td>
<td><font color="#008000">0.867<BR>
(0.00203s)</font></td>
<td>4.27<BR>
(0.01s)</td>
<td>5.94<BR>
(0.0139s)</td>
</tr>
<tr>
<td><code>^[^ ]*?Twain</code></td>
<td>5.72<BR>
(0.00626s)</td>
<td>15.5<BR>
(0.0169s)</td>
<td><font color="#008000">1<BR>
(0.00109s)</font></td>
<td><font color="#008000">0.644<BR>
(0.000704s)</font></td>
<td>NA</td>
<td>1.93<BR>
(0.00211s)</td>
</tr>
<tr>
<td><code>Tom|Sawyer|Huckleberry|Finn</code></td>
<td>7.85<BR>
(0.00828s)</td>
<td>19.9<BR>
(0.021s)</td>
<td><font color="#008000">1<BR>
(0.00105s)</font></td>
<td><font color="#008000">0.575<BR>
(0.000606s)</font></td>
<td>41.5<BR>
(0.0438s)</td>
<td><font color="#008000">1.09<BR>
(0.00115s)</font></td>
</tr>
<tr>
<td><code>(Tom|Sawyer|Huckleberry|Finn).{0,30}river|river.{0,30}(Tom|Sawyer|Huckleberry|Finn)</code></td>
<td>6.49<BR>
(0.012s)</td>
<td>16.5<BR>
(0.0307s)</td>
<td><font color="#008000">1<BR>
(0.00186s)</font></td>
<td><font color="#008000">0.737<BR>
(0.00137s)</font></td>
<td>216<BR>
(0.401s)</td>
<td>1.24<BR>
(0.00231s)</td>
</tr>
</table>
</P>
<H3>Comparison 3:&nbsp;C++ Code&nbsp;Search</H3>
<P>For each of the following regular expressions the time taken to find all
occurrences of the expression within the C++ source file <A href="../../../boost/crc.hpp">
boost/crc.hpp</A>&nbsp;was measured.&nbsp;</P>
<P><table border="1" cellspacing="1">
<tr>
<td><strong>Expression</strong></td>
<td><strong>GRETA</strong></td>
<td><strong>GRETA<BR>
(non-recursive mode)</strong></td>
<td><strong>Boost</strong></td>
<td><strong>Boost + C++ locale</strong></td>
<td><strong>POSIX</strong></td>
<td><strong>PCRE</strong></td>
</tr>
<tr>
<td><code>^(template[[:space:]]*&lt;[^;:{]+&gt;[[:space:]]*)?(class|struct)[[:space:]]*(\&lt;\w+\&gt;([
]*\([^)]*\))?[[:space:]]*)*(\&lt;\w*\&gt;)[[:space:]]*(&lt;[^;:{]+&gt;[[:space:]]*)?(\{|:[^;\{()]*\{)</code></td>
<td>9.58<BR>
(0.0019s)</td>
<td>40.3<BR>
(0.00798s)</td>
<td><font color="#008000">1<BR>
(0.000198s)</font></td>
<td><font color="#008000">0.901<BR>
(0.000178s)</font></td>
<td>607<BR>
(0.12s)</td>
<td>3.16<BR>
(0.000626s)</td>
</tr>
<tr>
<td><code>(^[
]*#(?:[^\\\n]|\\[^\n_[:punct:][:alnum:]]*[\n[:punct:][:word:]])*)|(//[^\n]*|/\*.*?\*/)|\&lt;([+-]?(?:(?:0x[[:xdigit:]]+)|(?:(?:[[:digit:]]*\.)?[[:digit:]]+(?:[eE][+-]?[[:digit:]]+)?))u?(?:(?:int(?:8|16|32|64))|L)?)\&gt;|('(?:[^\\']|\\.)*'|"(?:[^\\"]|\\.)*")|\&lt;(__asm|__cdecl|__declspec|__export|__far16|__fastcall|__fortran|__import|__pascal|__rtti|__stdcall|_asm|_cdecl|__except|_export|_far16|_fastcall|__finally|_fortran|_import|_pascal|_stdcall|__thread|__try|asm|auto|bool|break|case|catch|cdecl|char|class|const|const_cast|continue|default|delete|do|double|dynamic_cast|else|enum|explicit|extern|false|float|for|friend|goto|if|inline|int|long|mutable|namespace|new|operator|pascal|private|protected|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_cast|struct|switch|template|this|throw|true|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while)\&gt;</code></td>
<td><font color="#008000">1<BR>
(0.0116s)</font></td>
<td>2.7<BR>
(0.0313s)</td>
<td>1.22<BR>
(0.0141s)</td>
<td><font color="#008000">0.946<BR>
(0.011s)</font></td>
<td>NA</td>
<td>1.41<BR>
(0.0163s)</td>
</tr>
<tr>
<td><code>^[ ]*#[ ]*include[ ]+("[^"]+"|&lt;[^&gt;]+&gt;)</code></td>
<td>6.05<BR>
(0.00195s)</td>
<td>25.7<BR>
(0.0083s)</td>
<td><font color="#008000">1<BR>
(0.000323s)</font></td>
<td><font color="#008000">0.939<BR>
(0.000303s)</font></td>
<td>107<BR>
(0.0344s)</td>
<td>1.69<BR>
(0.000547s)</td>
</tr>
<tr>
<td><code>^[ ]*#[ ]*include[ ]+("boost/[^"]+"|<boost^[>]+&gt;)</code></td>
<td>5.8<BR>
(0.00196s)</td>
<td>24.6<BR>
(0.0083s)</td>
<td><font color="#008000">1<BR>
(0.000337s)</font></td>
<td><font color="#008000">1.07<BR>
(0.000362s)</font></td>
<td>122<BR>
(0.0413s)</td>
<td>1.59<BR>
(0.000538s)</td>
</tr>
</table>
</P>
<H3>
<H3>Comparison 4: HTML Document Search</H3>
</H3>
<P>For each of the following regular expressions the time taken to find all
occurrences of the expression within the html file <A href="../../libraries.htm">libs/libraries.htm</A>
was measured.&nbsp;</P>
<P><table border="1" cellspacing="1">
<tr>
<td><strong>Expression</strong></td>
<td><strong>GRETA</strong></td>
<td><strong>GRETA<BR>
(non-recursive mode)</strong></td>
<td><strong>Boost</strong></td>
<td><strong>Boost + C++ locale</strong></td>
<td><strong>POSIX</strong></td>
<td><strong>PCRE</strong></td>
</tr>
<tr>
<td><code>beman|john|dave</code></td>
<td>6.69<BR>
(0.00321s)</td>
<td>18.9<BR>
(0.00908s)</td>
<td><font color="#008000">1<BR>
(0.000479s)</font></td>
<td><font color="#008000">0.561<BR>
(0.000269s)</font></td>
<td>23.8<BR>
(0.0114s)</td>
<td><font color="#008000">1<BR>
(0.000479s)</font></td>
</tr>
<tr>
<td><code><p>.*?</p>
</code>
</td>
<td>5.89<BR>
(0.00164s)</td>
<td>19.6<BR>
(0.00548s)</td>
<td><font color="#008000">1<BR>
(0.000279s)</font></td>
<td><font color="#008000">1.05<BR>
(0.000293s)</font></td>
<td>NA</td>
<td>1.11<BR>
(0.000308s)</td>
</tr>
<tr>
<td><code><a^[>]+href=("[^"]*"|[^[:space:]]+)[^&gt;]*&gt;</code></td>
<td>3.94<BR>
(0.00219s)</td>
<td>10.4<BR>
(0.00579s)</td>
<td><font color="#008000">1.09<BR>
(0.000606s)</font></td>
<td><font color="#008000">0.825<BR>
(0.000459s)</font></td>
<td>221<BR>
(0.123s)</td>
<td><font color="#008000">1<BR>
(0.000557s)</font></td>
</tr>
<tr>
<td><code><h12345678][^[>]*&gt;.*?</h[12345678]></code></td>
<td>6.07<BR>
(0.0016s)</td>
<td>19.8<BR>
(0.00524s)</td>
<td>1.37<BR>
(0.000362s)</td>
<td><font color="#008000">0.722<BR>
(0.000191s)</font></td>
<td>NA</td>
<td><font color="#008000">1<BR>
(0.000264s)</font></td>
</tr>
<tr>
<td><code><img^[>]+src=("[^"]*"|[^[:space:]]+)[^&gt;]*&gt;</code></td>
<td>6.77<BR>
(0.00162s)</td>
<td>22.5<BR>
(0.0054s)</td>
<td>1.1<BR>
(0.000264s)</td>
<td>1.2<BR>
(0.000289s)</td>
<td>120<BR>
(0.0288s)</td>
<td><font color="#008000">1<BR>
(0.00024s)</font></td>
</tr>
<tr>
<td><code><font^[>]+face=("[^"]*"|[^[:space:]]+)[^&gt;]*&gt;.*?</font></code></td>
<td>6.77<BR>
(0.00162s)</td>
<td>22.5<BR>
(0.0054s)</td>
<td>1.12<BR>
(0.000269s)</td>
<td>1.2<BR>
(0.000289s)</td>
<td>NA</td>
<td><font color="#008000">1<BR>
(0.00024s)</font></td>
</tr>
</table>
</P>
<H3>Comparison 3: Simple Matches</H3>
<p>
For each of the following regular expressions the time taken to match against
the text indicated was measured.&nbsp;</p>
<P><table border="1" cellspacing="1">
<tr>
<td><strong>Expression</strong></td>
<td><strong>Text</strong></td>
<td><strong>GRETA</strong></td>
<td><strong>GRETA<BR>
(non-recursive mode)</strong></td>
<td><strong>Boost</strong></td>
<td><strong>Boost + C++ locale</strong></td>
<td><strong>POSIX</strong></td>
<td><strong>PCRE</strong></td>
</tr>
<tr>
<td><code>abc</code></td>
<td>abc</td>
<td>1.43<BR>
(2.25e-007s)</td>
<td>1.85<BR>
(2.91e-007s)</td>
<td>1.27<BR>
(2.01e-007s)</td>
<td>1.29<BR>
(2.03e-007s)</td>
<td>1.94<BR>
(3.06e-007s)</td>
<td><font color="#008000">1<BR>
(1.58e-007s)</font></td>
</tr>
<tr>
<td><code>^([0-9]+)(\-| |$)(.*)$</code></td>
<td>100- this is a line of ftp response which contains a message string</td>
<td><font color="#008000">1<BR>
(6.97e-007s)</font></td>
<td>2.69<BR>
(1.87e-006s)</td>
<td>1.89<BR>
(1.32e-006s)</td>
<td>1.86<BR>
(1.3e-006s)</td>
<td>298<BR>
(0.000208s)</td>
<td>1.29<BR>
(8.98e-007s)</td>
</tr>
<tr>
<td><code>([[:digit:]]{4}[- ]){3}[[:digit:]]{3,4}</code></td>
<td>1234-5678-1234-456</td>
<td>2.41<BR>
(2.14e-006s)</td>
<td>2.97<BR>
(2.64e-006s)</td>
<td>2.37<BR>
(2.1e-006s)</td>
<td>2.24<BR>
(1.99e-006s)</td>
<td>29.6<BR>
(2.63e-005s)</td>
<td><font color="#008000">1<BR>
(8.88e-007s)</font></td>
</tr>
<tr>
<td><code>^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$</code></td>
<td>john_maddock@compuserve.com</td>
<td>1.83<BR>
(3.7e-006s)</td>
<td>2.34<BR>
(4.74e-006s)</td>
<td>1.59<BR>
(3.21e-006s)</td>
<td>1.55<BR>
(3.13e-006s)</td>
<td>172<BR>
(0.000347s)</td>
<td><font color="#008000">1<BR>
(2.02e-006s)</font></td>
</tr>
<tr>
<td><code>^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$</code></td>
<td>foo12@foo.edu</td>
<td>1.71<BR>
(3.09e-006s)</td>
<td>2.19<BR>
(3.97e-006s)</td>
<td>1.71<BR>
(3.09e-006s)</td>
<td>1.64<BR>
(2.98e-006s)</td>
<td>123<BR>
(0.000222s)</td>
<td><font color="#008000">1<BR>
(1.81e-006s)</font></td>
</tr>
<tr>
<td><code>^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$</code></td>
<td>bob.smith@foo.tv</td>
<td>1.72<BR>
(3.09e-006s)</td>
<td>2.21<BR>
(3.97e-006s)</td>
<td>1.72<BR>
(3.09e-006s)</td>
<td>1.7<BR>
(3.06e-006s)</td>
<td>133<BR>
(0.00024s)</td>
<td><font color="#008000">1<BR>
(1.79e-006s)</font></td>
</tr>
<tr>
<td><code>^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$</code></td>
<td>EH10 2QQ</td>
<td>1.29<BR>
(9.37e-007s)</td>
<td>1.71<BR>
(1.24e-006s)</td>
<td>1.29<BR>
(9.35e-007s)</td>
<td>1.18<BR>
(8.59e-007s)</td>
<td>7.79<BR>
(5.65e-006s)</td>
<td><font color="#008000">1<BR>
(7.26e-007s)</font></td>
</tr>
<tr>
<td><code>^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$</code></td>
<td>G1 1AA</td>
<td>1.41<BR>
(9.26e-007s)</td>
<td>2<BR>
(1.32e-006s)</td>
<td>1.38<BR>
(9.07e-007s)</td>
<td>1.31<BR>
(8.6e-007s)</td>
<td>7.41<BR>
(4.88e-006s)</td>
<td><font color="#008000">1<BR>
(6.59e-007s)</font></td>
</tr>
<tr>
<td><code>^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$</code></td>
<td>SW1 1ZZ</td>
<td>1.45<BR>
(9.54e-007s)</td>
<td>1.88<BR>
(1.24e-006s)</td>
<td>1.42<BR>
(9.36e-007s)</td>
<td>1.32<BR>
(8.69e-007s)</td>
<td>7.77<BR>
(5.12e-006s)</td>
<td><font color="#008000">1<BR>
(6.59e-007s)</font></td>
</tr>
<tr>
<td><code>^[[:digit:]]{1,2}/[[:digit:]]{1,2}/[[:digit:]]{4}$</code></td>
<td>4/1/2001</td>
<td>1.74<BR>
(1.01e-006s)</td>
<td>2.3<BR>
(1.34e-006s)</td>
<td>1.33<BR>
(7.73e-007s)</td>
<td>1.3<BR>
(7.54e-007s)</td>
<td>9.85<BR>
(5.73e-006s)</td>
<td><font color="#008000">1<BR>
(5.82e-007s)</font></td>
</tr>
<tr>
<td><code>^[[:digit:]]{1,2}/[[:digit:]]{1,2}/[[:digit:]]{4}$</code></td>
<td>12/12/2001</td>
<td>1.77<BR>
(1.01e-006s)</td>
<td>2.23<BR>
(1.28e-006s)</td>
<td>1.45<BR>
(8.31e-007s)</td>
<td>1.38<BR>
(7.93e-007s)</td>
<td>11.1<BR>
(6.34e-006s)</td>
<td><font color="#008000">1<BR>
(5.73e-007s)</font></td>
</tr>
<tr>
<td><code>^[-+]?[[:digit:]]*\.?[[:digit:]]*$</code></td>
<td>123</td>
<td>1.23<BR>
(7.65e-007s)</td>
<td>1.66<BR>
(1.03e-006s)</td>
<td>1.4<BR>
(8.69e-007s)</td>
<td>1.31<BR>
(8.12e-007s)</td>
<td>4.86<BR>
(3.02e-006s)</td>
<td><font color="#008000">1<BR>
(6.21e-007s)</font></td>
</tr>
<tr>
<td><code>^[-+]?[[:digit:]]*\.?[[:digit:]]*$</code></td>
<td>+3.14159</td>
<td>1.59<BR>
(1.05e-006s)</td>
<td>1.97<BR>
(1.3e-006s)</td>
<td>1.45<BR>
(9.54e-007s)</td>
<td>1.32<BR>
(8.69e-007s)</td>
<td>9.51<BR>
(6.26e-006s)</td>
<td><font color="#008000">1<BR>
(6.59e-007s)</font></td>
</tr>
<tr>
<td><code>^[-+]?[[:digit:]]*\.?[[:digit:]]*$</code></td>
<td>-3.14159</td>
<td>1.64<BR>
(1.07e-006s)</td>
<td>2<BR>
(1.3e-006s)</td>
<td>1.44<BR>
(9.35e-007s)</td>
<td>1.35<BR>
(8.78e-007s)</td>
<td>9.53<BR>
(6.19e-006s)</td>
<td><font color="#008000">1<BR>
(6.49e-007s)</font></td>
</tr>
</table>
</P>
<hr>
<p>Copyright John Maddock September 2002, all rights reserved.</p>
</body>
</html>