forked from boostorg/regex
Completed perl feature set.
Merged in changes to Docs from main branch. [SVN r22785]
This commit is contained in:
1 parent
b5cf51fbc6
commit
bb264b055f
38 files changed
+2253
-1786
No files matched your search
@@ -24,6 +24,11 @@
|
||||
</P>
|
||||
<HR>
|
||||
<p></p>
|
||||
<P>Captures are the iterator ranges that are "captured" by marked sub-expressions
|
||||
as a regular expression gets matched. Each marked sub-expression can
|
||||
result in more than one capture, if it is matched more than once. This
|
||||
document explains how captures and marked sub-expressions in Boost.Regex are
|
||||
represented and accessed.</P>
|
||||
<H2>Marked sub-expressions</H2>
|
||||
<P>Every time a Perl regular expression contains a parenthesis group (), it spits
|
||||
out an extra field, known as a marked sub-expression, for example the
|
||||
@@ -247,4 +252,3 @@ Text: "now is the time for all good men to come to the aid of the party"
|
||||
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+27
-21
@@ -25,25 +25,32 @@
|
||||
<BR>
|
||||
<BR>
|
||||
<HR>
|
||||
<P>The author can be contacted at john@johnmaddock.co.uk; the
|
||||
home page for this library is at <A href="http://www.boost.org">www.boost.org</A>.</P>
|
||||
<P>I am indebted to Robert Sedgewick's "Algorithms in C++" for forcing me to think
|
||||
about algorithms and their performance, and to the folks at boost for forcing
|
||||
me to <I>think</I>, period. The following people have all contributed useful
|
||||
comments or fixes: Dave Abrahams, Mike Allison, Edan Ayal, Jayashree
|
||||
Balasubramanian, Jan Bölsche, Beman Dawes, Paul Baxter, David Bergman, David
|
||||
Dennerline, Edward Diener, Peter Dimov, Robert Dunn, Fabio Forno, Tobias
|
||||
Gabrielsson, Rob Gillen, Marc Gregoire, Chris Hecker, Nick Hodapp, Jesse Jones,
|
||||
Martin Jost, Boris Krasnovskiy, Jan Hermelink, Max Leung, Wei-hao Lin, Jens
|
||||
Maurer, Richard Peters, Heiko Schmidt, Jason Shirk, Gerald Slacik, Scobie
|
||||
Smith, Mike Smyth, Alexander Sokolovsky, Hervé Poirier, Michael Raykh, Marc
|
||||
Recht, Scott VanCamp, Bruno Voigt, Alexey Voinov, Jerry Waldorf, Rob Ward,
|
||||
Lealon Watts, Thomas Witt and Yuval Yosef. I am also grateful to the manuals
|
||||
supplied with the Henry Spencer, Perl and GNU regular expression libraries -
|
||||
wherever possible I have tried to maintain compatibility with these libraries
|
||||
and with the POSIX standard - the code however is entirely my own, including
|
||||
any bugs! I can absolutely guarantee that I will not fix any bugs I don't know
|
||||
about, so if you have any comments or spot any bugs, please get in touch.</P>
|
||||
<P>The author can be contacted at john@johnmaddock.co.uk; the home page for
|
||||
this library is at <A href="http://www.boost.org">www.boost.org</A>.</P>
|
||||
<P>I am indebted to <A href="http://www.cs.princeton.edu/~rs/">Robert Sedgewick's
|
||||
"Algorithms in C++" </A>for forcing me to think about algorithms and their
|
||||
performance, and to the folks at <A href="http://www.boost.org">boost</A> for
|
||||
forcing me to <I>think</I>, period.</P>
|
||||
<P><A href="http://www.boost-consulting.com">Eric Niebler</A>, author of the <A href="http://research.microsoft.com/projects/greta">
|
||||
GRETA regular expression component</A>, has shared several important ideas,
|
||||
in a series of long discussions.</P>
|
||||
<P>Pete Becker, of <A href="http://www.dinkumware.com/">Dinkumware Ltd</A>, has
|
||||
helped enormously with the standardisation proposal language.</P>
|
||||
<P>The following people have all contributed useful comments or fixes: Dave
|
||||
Abrahams, Mike Allison, Edan Ayal, Jayashree Balasubramanian, Jan Bölsche,
|
||||
Beman Dawes, Paul Baxter, David Bergman, David Dennerline, Edward Diener, Peter
|
||||
Dimov, Robert Dunn, Fabio Forno, Tobias Gabrielsson, Rob Gillen, Marc Gregoire,
|
||||
Chris Hecker, Nick Hodapp, Jesse Jones, Martin Jost, Boris Krasnovskiy, Jan
|
||||
Hermelink, Max Leung, Wei-hao Lin, Jens Maurer, Richard Peters, Heiko Schmidt,
|
||||
Jason Shirk, Gerald Slacik, Scobie Smith, Mike Smyth, Alexander Sokolovsky,
|
||||
Hervé Poirier, Michael Raykh, Marc Recht, Scott VanCamp, Bruno Voigt, Alexey
|
||||
Voinov, Jerry Waldorf, Rob Ward, Lealon Watts, John Wismar, Thomas Witt and
|
||||
Yuval Yosef. I am also grateful to the manuals supplied with the Henry Spencer,
|
||||
Perl and GNU regular expression libraries - wherever possible I have tried to
|
||||
maintain compatibility with these libraries and with the POSIX standard - the
|
||||
code however is entirely my own, including any bugs! I can absolutely guarantee
|
||||
that I will not fix any bugs I don't know about, so if you have any comments or
|
||||
spot any bugs, please get in touch.</P>
|
||||
<P>Useful further information can be found at:</P>
|
||||
<P>Short tutorials on regular expressions can be <A href="http://etext.lib.virginia.edu/helpsheets/regex.html">
|
||||
found here</A> and <A href="http://www.devshed.com/Server_Side/Administration/RegExp/page1.html">here</A>.</P>
|
||||
@@ -72,8 +79,7 @@
|
||||
24 Oct 2003
|
||||
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
|
||||
<p><i>© Copyright John Maddock 1998-
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
|
||||
2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||
<P><I>Use, modification and distribution are subject to the Boost Software License,
|
||||
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
|
||||
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
|
||||
|
||||
+95
-134
@@ -1,153 +1,114 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<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"> 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 <boost/regex.hpp> 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>
|
||||
<head>
|
||||
<title>Boost.Regex: FAQ</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></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"> 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
|
||||
<boost/regex.hpp> 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
|
||||
<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>
|
||||
<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, 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>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, 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 -->
|
||||
24 Oct 2003
|
||||
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
|
||||
<p><i>© Copyright John Maddock 1998-
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
|
||||
2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||
<P><I>Use, modification and distribution are subject to the Boost Software License,
|
||||
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
|
||||
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
|
||||
</body>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
@@ -26,14 +26,14 @@
|
||||
<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
|
||||
<p>The type <code>match_flag_type</code> is an implementation specific bitmask
|
||||
type (17.3.2.1.2) that controls how a regular expression is matched against a
|
||||
character sequence. The behavior of the format flags is descibed in more
|
||||
detail in the <A href="format_syntax.html">format syntax guide</A>.</p>
|
||||
<pre>
|
||||
namespace std{ namespace regex_constants{
|
||||
namespace boost{ namespace regex_constants{
|
||||
|
||||
typedef bitmask_type match_flag_type;
|
||||
typedef <EM>implemenation-specific-bitmask-type</EM> match_flag_type;
|
||||
|
||||
static const match_flag_type match_default = 0;
|
||||
static const match_flag_type match_not_bob;
|
||||
@@ -59,11 +59,11 @@ static const match_flag_type format_first_only;
|
||||
static const match_flag_type format_all;
|
||||
|
||||
} // namespace regex_constants
|
||||
} // namespace std
|
||||
} // namespace boost
|
||||
</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
|
||||
<p>The type <code>match_flag_type</code> is an implementation specific 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>
|
||||
@@ -271,10 +271,10 @@ static const match_flag_type format_all;
|
||||
<br>
|
||||
<p>Revised
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
|
||||
24 Oct 2003
|
||||
04 Feb 2004
|
||||
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
|
||||
<p><i>© Copyright John Maddock 1998-
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2004<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||
<P><I>Use, modification and distribution are subject to the Boost Software License,
|
||||
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
|
||||
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
|
||||
|
||||
@@ -344,7 +344,7 @@ const_iterator end()const;
|
||||
<p><b>Effects:</b> Returns a terminating iterator that enumerates over all the
|
||||
marked sub-expression matches stored in *this.</p>
|
||||
<h4><A name="format"></A>match_results reformatting</h4>
|
||||
<pre>template <class OutputIterator>
|
||||
<pre><A name=m12></A>template <class OutputIterator>
|
||||
OutputIterator format(OutputIterator out,
|
||||
const string_type& fmt,
|
||||
<A href="match_flag_type.html" >match_flag_type</A> flags = format_default);
|
||||
|
||||
+434
-564
File diff suppressed because it is too large.
Load diff
@@ -42,7 +42,7 @@
|
||||
iterator first,
|
||||
iterator last,
|
||||
<b>const</b> basic_regex<charT, traits, Allocator>& e,
|
||||
<b>unsigned</b> flags = match_default)
|
||||
boost::match_flag_type 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<>& in place of a pair of
|
||||
@@ -53,13 +53,13 @@
|
||||
<b>unsigned</b> <b>int</b> regex_grep(Predicate foo,
|
||||
<b>const</b> charT* str,
|
||||
<b>const</b> basic_regex<charT, traits, Allocator>& e,
|
||||
<b>unsigned</b> flags = match_default);
|
||||
boost::match_flag_type flags = match_default);
|
||||
|
||||
<b>template</b> <<b>class</b> Predicate, <b>class</b> ST, <b>class</b> SA, <b>class</b> Allocator, <b>class</b> charT, <b>class</b> traits>
|
||||
<b>unsigned</b> <b>int</b> regex_grep(Predicate foo,
|
||||
<b>const</b> std::basic_string<charT, ST, SA>& s,
|
||||
<b>const</b> basic_regex<charT, traits, Allocator>& e,
|
||||
<b>unsigned</b> flags = match_default);
|
||||
boost::match_flag_type flags = match_default);
|
||||
</pre>
|
||||
<p>The parameters for the primary version of regex_grep have the following
|
||||
meanings: </p>
|
||||
@@ -370,11 +370,10 @@ index[std::string(what[5].first, what[5].second) + std::string(what[6].first, wh
|
||||
<hr>
|
||||
<p>Revised
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
|
||||
24 Oct 2003
|
||||
04 Feb 2004
|
||||
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
|
||||
<p><i>© Copyright John Maddock 1998-
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
|
||||
2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2004<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||
<P><I>Use, modification and distribution are subject to the Boost Software License,
|
||||
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
|
||||
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
|
||||
|
||||
@@ -294,7 +294,7 @@ void</B> IndexClasses(map_type& m, <B>const</B> std::string& file)
|
||||
start = file.begin();
|
||||
end = file.end();
|
||||
boost::<a href="match_results.html">match_results</a><std::string::const_iterator> what;
|
||||
<B>unsigned</B> <B>int</B> flags = boost::match_default;
|
||||
boost::match_flag_type flags = boost::match_default;
|
||||
<B>while</B>(regex_search(start, end, what, expression, flags))
|
||||
{
|
||||
<FONT color=#000080> <I>// what[0] contains the whole string
|
||||
@@ -314,11 +314,10 @@ void</B> IndexClasses(map_type& m, <B>const</B> std::string& file)
|
||||
<HR>
|
||||
<p>Revised
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
|
||||
24 Oct 2003
|
||||
04 Feb 2004
|
||||
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
|
||||
<p><i>© Copyright John Maddock 1998-
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
|
||||
2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2004<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||
<P><I>Use, modification and distribution are subject to the Boost Software License,
|
||||
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
|
||||
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
|
||||
|
||||
@@ -38,15 +38,15 @@
|
||||
<PRE><B>template</B> <<B>class</B> OutputIterator, <B>class</B> charT, <B>class</B> Traits1, <B>class</B> Alloc1, <B>class</B> Traits2, <B>class</B> Alloc2>
|
||||
std::size_t regex_split(OutputIterator out,
|
||||
std::basic_string<charT, Traits1, Alloc1>& s,
|
||||
<B> const</B> basic_regex<charT, Traits2, Alloc2>& e,
|
||||
<B> unsigned</B> flags,
|
||||
<B> const</B> basic_regex<charT, Traits2, Alloc2>& e,
|
||||
<STRONG> </STRONG>boost::match_flag_type flags,
|
||||
std::size_t max_split);
|
||||
|
||||
<B>template</B> <<B>class</B> OutputIterator, <B>class</B> charT, <B>class</B> Traits1, <B>class</B> Alloc1, <B>class</B> Traits2, <B>class</B> Alloc2>
|
||||
std::size_t regex_split(OutputIterator out,
|
||||
std::basic_string<charT, Traits1, Alloc1>& s,
|
||||
<B> const</B> basic_regex<charT, Traits2, Alloc2>& e,
|
||||
<B>unsigned</B> flags = match_default);
|
||||
<B> const</B> basic_regex<charT, Traits2, Alloc2>& e,
|
||||
boost::match_flag_type flags = match_default);
|
||||
|
||||
<B>template</B> <<B>class</B> OutputIterator, <B>class</B> charT, <B>class</B> Traits1, <B>class</B> Alloc1>
|
||||
std::size_t regex_split(OutputIterator out,
|
||||
@@ -134,11 +134,10 @@ boost::regex e(<FONT color=#000080>"<\\s*A\\s+[^>]*href\\s*=\\s*\"([^\"]*)
|
||||
<HR>
|
||||
<p>Revised
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
|
||||
24 Oct 2003
|
||||
04 Feb 2004
|
||||
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
|
||||
<p><i>© Copyright John Maddock 1998-
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
|
||||
2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2004<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||
<P><I>Use, modification and distribution are subject to the Boost Software License,
|
||||
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
|
||||
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
|
||||
|
||||
@@ -76,7 +76,7 @@ typedef regex_token_iterator<const char*> cregex_token_i
|
||||
typedef regex_token_iterator<std::string::const_iterator> sregex_token_iterator;
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator;
|
||||
typedef regex_token_iterator<<std::wstring::const_iterator> wsregex_token_iterator;
|
||||
typedef regex_token_iterator<<std::wstring::const_iterator> wsregex_token_iterator;
|
||||
#endif
|
||||
</PRE>
|
||||
<H3><A name="description"></A>Description</H3>
|
||||
@@ -84,7 +84,8 @@ typedef regex_token_iterator<<std::wstring::const_iterator> wsregex_token_
|
||||
<P><B> Effects:</B> constructs an end of sequence iterator.</P>
|
||||
<PRE><A name=c2></A>regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re,
|
||||
int submatch = 0, match_flag_type m = match_default);</PRE>
|
||||
<P><B> Preconditions: </B><CODE>!re.empty()</CODE>.</P>
|
||||
<P><B> Preconditions: </B><CODE>!re.empty()</CODE>. Object re shall exist
|
||||
for the lifetime of the iterator constructed from it.</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>. The
|
||||
@@ -99,7 +100,8 @@ typedef regex_token_iterator<<std::wstring::const_iterator> wsregex_token_
|
||||
configured</A> in non-recursive mode).</P>
|
||||
<PRE><A name=c3></A>regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re,
|
||||
const std::vector<int>& submatches, match_flag_type m = match_default);</PRE>
|
||||
<P><B> Preconditions:</B> <CODE>submatches.size() && !re.empty()</CODE>.</P>
|
||||
<P><B> Preconditions:</B> <CODE>submatches.size() && !re.empty()</CODE>.
|
||||
Object re shall exist for the lifetime of the iterator constructed from it.</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>. For
|
||||
@@ -118,7 +120,8 @@ typedef regex_token_iterator<<std::wstring::const_iterator> wsregex_token_
|
||||
<PRE><A name=c4></A>template <std::size_t N>
|
||||
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re,
|
||||
const int (&submatches)[R], match_flag_type m = match_default);</PRE>
|
||||
<P><B> Preconditions: </B><CODE>!re.empty()</CODE>.</P>
|
||||
<P><B> Preconditions: </B><CODE>!re.empty()</CODE>. Object re shall exist
|
||||
for the lifetime of the iterator constructed from it.</P>
|
||||
<P><STRONG>Effects:</STRONG></B> constructs a regex_token_iterator that will
|
||||
enumerate <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
|
||||
|
||||
@@ -24,10 +24,12 @@
|
||||
</P>
|
||||
<HR>
|
||||
<p></p>
|
||||
<P>Under construction.</P>
|
||||
<P>The current boost.regex traits class design will be migrated to that specified
|
||||
in the <A href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1429.htm">regular
|
||||
expression standardization proposal</A>. </P>
|
||||
<P>
|
||||
Under construction: the current design will be replaced by that specified in
|
||||
the <A href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1429.htm">regular
|
||||
expression standardization proposal</A>, the current (obsolete) design has
|
||||
it's <A href="http://cvs.sourceforge.net/viewcvs.py/*checkout*/boost/boost/libs/regex/Attic/traits_class_ref.htm?rev=1.11">
|
||||
documentation archived online</A>.</P>
|
||||
<P>
|
||||
<HR>
|
||||
<P></P>
|
||||
@@ -36,11 +38,9 @@
|
||||
24 Oct 2003
|
||||
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
|
||||
<p><i>© Copyright John Maddock 1998-
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
|
||||
2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||
<P><I>Use, modification and distribution are subject to the Boost Software License,
|
||||
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
|
||||
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+98
-101
@@ -91,18 +91,18 @@
|
||||
<P>Parentheses serve two purposes, to group items together into a sub-expression,
|
||||
and to mark what generated the match. For example the expression "(ab)*" would
|
||||
match all of the string "ababab". The matching algorithms <A href="regex_match.html">
|
||||
regex_match</A> and <A href="regex_search.html">regex_search</A>
|
||||
each take an instance of <A href="match_results.html">match_results</A>
|
||||
that reports what caused the match, on exit from these functions the <A href="match_results.html">
|
||||
match_results</A> contains information both on what the whole expression
|
||||
matched and on what each sub-expression matched. In the example above
|
||||
match_results[1] would contain a pair of iterators denoting the final "ab" of
|
||||
the matching string. It is permissible for sub-expressions to match null
|
||||
strings. If a sub-expression takes no part in a match - for example if it is
|
||||
part of an alternative that is not taken - then both of the iterators that are
|
||||
returned for that sub-expression point to the end of the input string, and the <I>matched</I>
|
||||
parameter for that sub-expression is <I>false</I>. Sub-expressions are indexed
|
||||
from left to right starting from 1, sub-expression 0 is the whole expression.
|
||||
regex_match</A> and <A href="regex_search.html">regex_search</A> each take
|
||||
an instance of <A href="match_results.html">match_results</A> that reports what
|
||||
caused the match, on exit from these functions the <A href="match_results.html">match_results</A>
|
||||
contains information both on what the whole expression matched and on what each
|
||||
sub-expression matched. In the example above match_results[1] would contain a
|
||||
pair of iterators denoting the final "ab" of the matching string. It is
|
||||
permissible for sub-expressions to match null strings. If a sub-expression
|
||||
takes no part in a match - for example if it is part of an alternative that is
|
||||
not taken - then both of the iterators that are returned for that
|
||||
sub-expression point to the end of the input string, and the <I>matched</I> parameter
|
||||
for that sub-expression is <I>false</I>. Sub-expressions are indexed from left
|
||||
to right starting from 1, sub-expression 0 is the whole expression.
|
||||
</P>
|
||||
<H3>Non-Marking Parenthesis
|
||||
</H3>
|
||||
@@ -143,7 +143,7 @@
|
||||
<P>A set is a set of characters that can match any single character that is a
|
||||
member of the set. Sets are delimited by "[" and "]" and can contain literals,
|
||||
character ranges, character classes, collating elements and equivalence
|
||||
classes. Set declarations that start with "^" contain the compliment of the
|
||||
classes. Set declarations that start with "^" contain the complement of the
|
||||
elements that follow.
|
||||
</P>
|
||||
<P>Examples:
|
||||
@@ -293,7 +293,7 @@
|
||||
[^[.ae.]] would only match one character.
|
||||
</P>
|
||||
<P>
|
||||
Equivalence classes take the general form[=tagname=] inside a set declaration,
|
||||
Equivalence classes take the generalform[=tagname=] inside a set declaration,
|
||||
where <I>tagname</I> is either a single character, or a name of a collating
|
||||
element, and matches any character that is a member of the same primary
|
||||
equivalence class as the collating element [.tagname.]. An equivalence class is
|
||||
@@ -302,7 +302,7 @@
|
||||
typically collated by character, then by accent, and then by case; the primary
|
||||
sort key then relates to the character, the secondary to the accentation, and
|
||||
the tertiary to the case). If there is no equivalence class corresponding to <I>tagname</I>
|
||||
, then[=tagname=] is exactly the same as [.tagname.]. Unfortunately there is no
|
||||
,then[=tagname=] is exactly the same as [.tagname.]. Unfortunately there is no
|
||||
locale independent method of obtaining the primary sort key for a character,
|
||||
except under Win32. For other operating systems the library will "guess" the
|
||||
primary sort key from the full sort key (obtained from <I>strxfrm</I>), so
|
||||
@@ -666,106 +666,103 @@
|
||||
<H3>What gets matched?
|
||||
</H3>
|
||||
<P>
|
||||
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.</P>
|
||||
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.</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
|
||||
string starting at a given location can match then it matches the longest
|
||||
possible string, unless the flag match_any is set, in which case the first
|
||||
match encountered is returned. Use of the match_any option can reduce the time
|
||||
taken to find the match - but is only useful if the user is less concerned
|
||||
about what matched - for example it would not be suitable for search and
|
||||
replace operations. In cases where their are multiple possible matches all
|
||||
starting at the same location, and all of the same length, then the match
|
||||
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
|
||||
POSIX regular expression matching rules:
|
||||
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
|
||||
string starting at a given location can match then it matches the longest
|
||||
possible string, unless the flag match_any is set, in which case the first
|
||||
match encountered is returned. Use of the match_any option can reduce the time
|
||||
taken to find the match - but is only useful if the user is less concerned
|
||||
about what matched - for example it would not be suitable for search and
|
||||
replace operations. In cases where their are multiple possible matches all
|
||||
starting at the same location, and all of the same length, then the match
|
||||
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>
|
||||
<TABLE id="Table5" cellSpacing="1" cellPadding="7" width="624" border="1">
|
||||
<TBODY>
|
||||
<TR>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P>Expression</P>
|
||||
</TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P>Text</P>
|
||||
</TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P>POSIX leftmost longest match</P>
|
||||
</TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P>ECMAScript depth first search match</P>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE>a|ab</CODE></P>
|
||||
</TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE>
|
||||
xaby</CODE>
|
||||
The following table examples illustrate the main differences between Perl and
|
||||
POSIX regular expression matching rules:
|
||||
</P>
|
||||
</TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE>
|
||||
"ab"</CODE></P></TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE>
|
||||
"a"</CODE></P></TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE>
|
||||
.*([[:alnum:]]+).*</CODE></P></TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE>
|
||||
" abc def xyz "</CODE></P></TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P>$0 = " abc def xyz "<BR>
|
||||
$1 = "abc"</P>
|
||||
</TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P>$0 = " abc def xyz "<BR>
|
||||
$1 = "z"</P>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE>
|
||||
.*(a|xayy)</CODE></P></TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE>
|
||||
zzxayyzz</CODE></P></TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE>
|
||||
"zzxayy"</CODE></P></TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE>"zzxa"</CODE></P>
|
||||
</TD>
|
||||
</TR>
|
||||
</TBODY></CODE></TD></TR></TABLE>
|
||||
<P>
|
||||
<TABLE id="Table5" cellSpacing="1" cellPadding="7" width="624" border="1">
|
||||
<TBODY>
|
||||
<TR>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P>Expression</P>
|
||||
</TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P>Text</P>
|
||||
</TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P>POSIX leftmost longest match</P>
|
||||
</TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P>ECMAScript depth first search match</P>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE>a|ab</CODE></P>
|
||||
</TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE> xaby</CODE>
|
||||
</P>
|
||||
</TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE> "ab"</CODE></P>
|
||||
</TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE> "a"</CODE></P>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE> .*([[:alnum:]]+).*</CODE></P>
|
||||
</TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE> " abc def xyz "</CODE></P>
|
||||
</TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P>$0 = " abc def xyz "<BR>
|
||||
$1 = "abc"</P>
|
||||
</TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P>$0 = " abc def xyz "<BR>
|
||||
$1 = "z"</P>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE> .*(a|xayy)</CODE></P>
|
||||
</TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE> zzxayyzz</CODE></P>
|
||||
</TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE> "zzxayy"</CODE></P>
|
||||
</TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE>"zzxa"</CODE></P>
|
||||
</TD>
|
||||
</TR>
|
||||
</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.</p>
|
||||
<HR>
|
||||
algorithms used to traverse the state machine.</P>
|
||||
<HR>
|
||||
<p>Revised
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
|
||||
24 Oct 2003
|
||||
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
|
||||
<p><i>© Copyright John Maddock 1998-
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
|
||||
2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||
<P><I>Use, modification and distribution are subject to the Boost Software License,
|
||||
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
|
||||
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
@@ -24,13 +24,15 @@
|
||||
</P>
|
||||
<HR>
|
||||
<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. For convenience
|
||||
note that all the constants listed here, are also duplicated within the scope
|
||||
of class template <A href="basic_regex.html">basic_regex</A>.</P>
|
||||
<P>Type syntax_option type is an implementation specific bitmask type that
|
||||
controls how a regular expression string is to be interpreted. For
|
||||
convenience note that all the constants listed here, are also duplicated within
|
||||
the scope of class template <A href="basic_regex.html">basic_regex</A>.</P>
|
||||
<PRE>namespace std{ namespace regex_constants{
|
||||
|
||||
typedef bitmask_type syntax_option_type;
|
||||
typedef <EM>implementation-specific-bitmask-type</EM>
|
||||
|
||||
syntax_option_type;
|
||||
// these flags are standardized:
|
||||
static const syntax_option_type normal;
|
||||
static const syntax_option_type icase;
|
||||
@@ -50,7 +52,7 @@ static const syntax_option_type perl;<BR>// these are boost.regex specific:<BR>s
|
||||
} // namespace regex_constants
|
||||
} // namespace std</PRE>
|
||||
<H3>Description</H3>
|
||||
<P>The type <CODE>syntax_option_type</CODE> is an implementation defined bitmask
|
||||
<P>The type <CODE>syntax_option_type</CODE> is an implementation specific bitmask
|
||||
type (17.3.2.1.2). Setting its elements has the effects listed in the table
|
||||
below, a valid value of type <CODE>syntax_option_type</CODE> will always have
|
||||
exactly one of the elements <CODE>normal, basic, extended, awk, grep, egrep, sed
|
||||
@@ -314,18 +316,15 @@ static const syntax_option_type perl;<BR>// these are boost.regex specific:<BR>s
|
||||
</TR>
|
||||
</TABLE>
|
||||
</P>
|
||||
<HR>
|
||||
<HR>
|
||||
<p>Revised
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
|
||||
24 Oct 2003
|
||||
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
|
||||
<p><i>© Copyright John Maddock 1998-
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
|
||||
2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||
<P><I>Use, modification and distribution are subject to the Boost Software License,
|
||||
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
|
||||
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
+5
-1
@@ -24,6 +24,11 @@
|
||||
</P>
|
||||
<HR>
|
||||
<p></p>
|
||||
<P>Captures are the iterator ranges that are "captured" by marked sub-expressions
|
||||
as a regular expression gets matched. Each marked sub-expression can
|
||||
result in more than one capture, if it is matched more than once. This
|
||||
document explains how captures and marked sub-expressions in Boost.Regex are
|
||||
represented and accessed.</P>
|
||||
<H2>Marked sub-expressions</H2>
|
||||
<P>Every time a Perl regular expression contains a parenthesis group (), it spits
|
||||
out an extra field, known as a marked sub-expression, for example the
|
||||
@@ -247,4 +252,3 @@ Text: "now is the time for all good men to come to the aid of the party"
|
||||
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+27
-21
@@ -25,25 +25,32 @@
|
||||
<BR>
|
||||
<BR>
|
||||
<HR>
|
||||
<P>The author can be contacted at john@johnmaddock.co.uk; the
|
||||
home page for this library is at <A href="http://www.boost.org">www.boost.org</A>.</P>
|
||||
<P>I am indebted to Robert Sedgewick's "Algorithms in C++" for forcing me to think
|
||||
about algorithms and their performance, and to the folks at boost for forcing
|
||||
me to <I>think</I>, period. The following people have all contributed useful
|
||||
comments or fixes: Dave Abrahams, Mike Allison, Edan Ayal, Jayashree
|
||||
Balasubramanian, Jan Bölsche, Beman Dawes, Paul Baxter, David Bergman, David
|
||||
Dennerline, Edward Diener, Peter Dimov, Robert Dunn, Fabio Forno, Tobias
|
||||
Gabrielsson, Rob Gillen, Marc Gregoire, Chris Hecker, Nick Hodapp, Jesse Jones,
|
||||
Martin Jost, Boris Krasnovskiy, Jan Hermelink, Max Leung, Wei-hao Lin, Jens
|
||||
Maurer, Richard Peters, Heiko Schmidt, Jason Shirk, Gerald Slacik, Scobie
|
||||
Smith, Mike Smyth, Alexander Sokolovsky, Hervé Poirier, Michael Raykh, Marc
|
||||
Recht, Scott VanCamp, Bruno Voigt, Alexey Voinov, Jerry Waldorf, Rob Ward,
|
||||
Lealon Watts, Thomas Witt and Yuval Yosef. I am also grateful to the manuals
|
||||
supplied with the Henry Spencer, Perl and GNU regular expression libraries -
|
||||
wherever possible I have tried to maintain compatibility with these libraries
|
||||
and with the POSIX standard - the code however is entirely my own, including
|
||||
any bugs! I can absolutely guarantee that I will not fix any bugs I don't know
|
||||
about, so if you have any comments or spot any bugs, please get in touch.</P>
|
||||
<P>The author can be contacted at john@johnmaddock.co.uk; the home page for
|
||||
this library is at <A href="http://www.boost.org">www.boost.org</A>.</P>
|
||||
<P>I am indebted to <A href="http://www.cs.princeton.edu/~rs/">Robert Sedgewick's
|
||||
"Algorithms in C++" </A>for forcing me to think about algorithms and their
|
||||
performance, and to the folks at <A href="http://www.boost.org">boost</A> for
|
||||
forcing me to <I>think</I>, period.</P>
|
||||
<P><A href="http://www.boost-consulting.com">Eric Niebler</A>, author of the <A href="http://research.microsoft.com/projects/greta">
|
||||
GRETA regular expression component</A>, has shared several important ideas,
|
||||
in a series of long discussions.</P>
|
||||
<P>Pete Becker, of <A href="http://www.dinkumware.com/">Dinkumware Ltd</A>, has
|
||||
helped enormously with the standardisation proposal language.</P>
|
||||
<P>The following people have all contributed useful comments or fixes: Dave
|
||||
Abrahams, Mike Allison, Edan Ayal, Jayashree Balasubramanian, Jan Bölsche,
|
||||
Beman Dawes, Paul Baxter, David Bergman, David Dennerline, Edward Diener, Peter
|
||||
Dimov, Robert Dunn, Fabio Forno, Tobias Gabrielsson, Rob Gillen, Marc Gregoire,
|
||||
Chris Hecker, Nick Hodapp, Jesse Jones, Martin Jost, Boris Krasnovskiy, Jan
|
||||
Hermelink, Max Leung, Wei-hao Lin, Jens Maurer, Richard Peters, Heiko Schmidt,
|
||||
Jason Shirk, Gerald Slacik, Scobie Smith, Mike Smyth, Alexander Sokolovsky,
|
||||
Hervé Poirier, Michael Raykh, Marc Recht, Scott VanCamp, Bruno Voigt, Alexey
|
||||
Voinov, Jerry Waldorf, Rob Ward, Lealon Watts, John Wismar, Thomas Witt and
|
||||
Yuval Yosef. I am also grateful to the manuals supplied with the Henry Spencer,
|
||||
Perl and GNU regular expression libraries - wherever possible I have tried to
|
||||
maintain compatibility with these libraries and with the POSIX standard - the
|
||||
code however is entirely my own, including any bugs! I can absolutely guarantee
|
||||
that I will not fix any bugs I don't know about, so if you have any comments or
|
||||
spot any bugs, please get in touch.</P>
|
||||
<P>Useful further information can be found at:</P>
|
||||
<P>Short tutorials on regular expressions can be <A href="http://etext.lib.virginia.edu/helpsheets/regex.html">
|
||||
found here</A> and <A href="http://www.devshed.com/Server_Side/Administration/RegExp/page1.html">here</A>.</P>
|
||||
@@ -72,8 +79,7 @@
|
||||
24 Oct 2003
|
||||
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
|
||||
<p><i>© Copyright John Maddock 1998-
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
|
||||
2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||
<P><I>Use, modification and distribution are subject to the Boost Software License,
|
||||
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
|
||||
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
|
||||
|
||||
+95
-134
@@ -1,153 +1,114 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<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"> 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 <boost/regex.hpp> 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>
|
||||
<head>
|
||||
<title>Boost.Regex: FAQ</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></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"> 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
|
||||
<boost/regex.hpp> 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
|
||||
<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>
|
||||
<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, 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>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, 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 -->
|
||||
24 Oct 2003
|
||||
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
|
||||
<p><i>© Copyright John Maddock 1998-
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
|
||||
2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||
<P><I>Use, modification and distribution are subject to the Boost Software License,
|
||||
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
|
||||
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
|
||||
</body>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
+23
-4
@@ -46,10 +46,10 @@
|
||||
<dl class="index">
|
||||
<dt><a href="syntax_option_type.html">syntax_option_type</a></dt> <dt><a href="match_flag_type.html">
|
||||
match_flag_type</a></dt> <dt><a href="bad_expression.html">class bad_expression</a></dt>
|
||||
<dt><a href="regex_traits.html">class regex_traits</a></dt> <dt><a href="basic_regex.html">
|
||||
class template basic_regex</a></dt> <dt><a href="sub_match.html">class template
|
||||
sub_match</a></dt> <dt><a href="match_results.html">class template
|
||||
match_results</a></dt>
|
||||
<dt><a href="regex_traits.html">class regex_traits</a></dt>
|
||||
<dt><a href="basic_regex.html">class template basic_regex</a></dt>
|
||||
<dt><a href="sub_match.html">class template sub_match</a></dt>
|
||||
<dt><a href="match_results.html">class template match_results</a></dt>
|
||||
</dl>
|
||||
</dd>
|
||||
<dt>Algorithms</dt>
|
||||
@@ -66,6 +66,25 @@
|
||||
<dt><a href="regex_token_iterator.html">regex_token_iterator</a></dt>
|
||||
</dl>
|
||||
</dd>
|
||||
<dt>Typedefs</dt>
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="basic_regex.html">regex</a> [ = basic_regex<char> ]</dt>
|
||||
<dt><a href="basic_regex.html">wregex</a> [ = basic_regex<wchar_t> ]</dt>
|
||||
<dt><a href="match_results.html">cmatch</a> [ = match_results<const char*> ]</dt>
|
||||
<dt><a href="match_results.html">wcmatch</a> [ = match_results<const wchar_t*> ]</dt>
|
||||
<dt><a href="match_results.html">smatch</a> [ = match_results<std::string::const_iterator> ]</dt>
|
||||
<dt><a href="match_results.html">wsmatch</a> [ = match_results<std::wstring::const_iterator> ]</dt>
|
||||
<dt><a href="regex_iterator.html">cregex_iterator</a> [ = regex_iterator<const char*>]</dt>
|
||||
<dt><a href="regex_iterator.html">wcregex_iterator</a> [ = regex_iterator<const wchar_t*>]</dt>
|
||||
<dt><a href="regex_iterator.html">sregex_iterator</a> [ = regex_iterator<std::string::const_iterator>]</dt>
|
||||
<dt><a href="regex_iterator.html">wsregex_iterator</a> [ = regex_iterator<std::wstring::const_iterator>]</dt>
|
||||
<dt><a href="regex_token_iterator.html">cregex_token_iterator</a> [ = regex_token_iterator<const char*>]</dt>
|
||||
<dt><a href="regex_token_iterator.html">wcregex_token_iterator</a> [ = regex_token_iterator<const wchar_t*>]</dt>
|
||||
<dt><a href="regex_token_iterator.html">sregex_token_iterator</a> [ = regex_token_iterator<std::string::const_iterator>]</dt>
|
||||
<dt><a href="regex_token_iterator.html">wsregex_token_iterator</a> [ = regex_token_iterator<std::wstring::const_iterator>]</dt>
|
||||
</dl>
|
||||
</dd>
|
||||
<dt>Misc.</dt>
|
||||
<dd>
|
||||
<dl class="index">
|
||||
|
||||
@@ -26,14 +26,14 @@
|
||||
<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
|
||||
<p>The type <code>match_flag_type</code> is an implementation specific bitmask
|
||||
type (17.3.2.1.2) that controls how a regular expression is matched against a
|
||||
character sequence. The behavior of the format flags is descibed in more
|
||||
detail in the <A href="format_syntax.html">format syntax guide</A>.</p>
|
||||
<pre>
|
||||
namespace std{ namespace regex_constants{
|
||||
namespace boost{ namespace regex_constants{
|
||||
|
||||
typedef bitmask_type match_flag_type;
|
||||
typedef <EM>implemenation-specific-bitmask-type</EM> match_flag_type;
|
||||
|
||||
static const match_flag_type match_default = 0;
|
||||
static const match_flag_type match_not_bob;
|
||||
@@ -59,11 +59,11 @@ static const match_flag_type format_first_only;
|
||||
static const match_flag_type format_all;
|
||||
|
||||
} // namespace regex_constants
|
||||
} // namespace std
|
||||
} // namespace boost
|
||||
</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
|
||||
<p>The type <code>match_flag_type</code> is an implementation specific 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>
|
||||
@@ -271,10 +271,10 @@ static const match_flag_type format_all;
|
||||
<br>
|
||||
<p>Revised
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
|
||||
24 Oct 2003
|
||||
04 Feb 2004
|
||||
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
|
||||
<p><i>© Copyright John Maddock 1998-
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2004<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||
<P><I>Use, modification and distribution are subject to the Boost Software License,
|
||||
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
|
||||
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
|
||||
|
||||
@@ -344,7 +344,7 @@ const_iterator end()const;
|
||||
<p><b>Effects:</b> Returns a terminating iterator that enumerates over all the
|
||||
marked sub-expression matches stored in *this.</p>
|
||||
<h4><A name="format"></A>match_results reformatting</h4>
|
||||
<pre>template <class OutputIterator>
|
||||
<pre><A name=m12></A>template <class OutputIterator>
|
||||
OutputIterator format(OutputIterator out,
|
||||
const string_type& fmt,
|
||||
<A href="match_flag_type.html" >match_flag_type</A> flags = format_default);
|
||||
|
||||
+434
-564
File diff suppressed because it is too large.
Load diff
+5
-6
@@ -42,7 +42,7 @@
|
||||
iterator first,
|
||||
iterator last,
|
||||
<b>const</b> basic_regex<charT, traits, Allocator>& e,
|
||||
<b>unsigned</b> flags = match_default)
|
||||
boost::match_flag_type 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<>& in place of a pair of
|
||||
@@ -53,13 +53,13 @@
|
||||
<b>unsigned</b> <b>int</b> regex_grep(Predicate foo,
|
||||
<b>const</b> charT* str,
|
||||
<b>const</b> basic_regex<charT, traits, Allocator>& e,
|
||||
<b>unsigned</b> flags = match_default);
|
||||
boost::match_flag_type flags = match_default);
|
||||
|
||||
<b>template</b> <<b>class</b> Predicate, <b>class</b> ST, <b>class</b> SA, <b>class</b> Allocator, <b>class</b> charT, <b>class</b> traits>
|
||||
<b>unsigned</b> <b>int</b> regex_grep(Predicate foo,
|
||||
<b>const</b> std::basic_string<charT, ST, SA>& s,
|
||||
<b>const</b> basic_regex<charT, traits, Allocator>& e,
|
||||
<b>unsigned</b> flags = match_default);
|
||||
boost::match_flag_type flags = match_default);
|
||||
</pre>
|
||||
<p>The parameters for the primary version of regex_grep have the following
|
||||
meanings: </p>
|
||||
@@ -370,11 +370,10 @@ index[std::string(what[5].first, what[5].second) + std::string(what[6].first, wh
|
||||
<hr>
|
||||
<p>Revised
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
|
||||
24 Oct 2003
|
||||
04 Feb 2004
|
||||
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
|
||||
<p><i>© Copyright John Maddock 1998-
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
|
||||
2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2004<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||
<P><I>Use, modification and distribution are subject to the Boost Software License,
|
||||
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
|
||||
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
|
||||
|
||||
@@ -294,7 +294,7 @@ void</B> IndexClasses(map_type& m, <B>const</B> std::string& file)
|
||||
start = file.begin();
|
||||
end = file.end();
|
||||
boost::<a href="match_results.html">match_results</a><std::string::const_iterator> what;
|
||||
<B>unsigned</B> <B>int</B> flags = boost::match_default;
|
||||
boost::match_flag_type flags = boost::match_default;
|
||||
<B>while</B>(regex_search(start, end, what, expression, flags))
|
||||
{
|
||||
<FONT color=#000080> <I>// what[0] contains the whole string
|
||||
@@ -314,11 +314,10 @@ void</B> IndexClasses(map_type& m, <B>const</B> std::string& file)
|
||||
<HR>
|
||||
<p>Revised
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
|
||||
24 Oct 2003
|
||||
04 Feb 2004
|
||||
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
|
||||
<p><i>© Copyright John Maddock 1998-
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
|
||||
2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2004<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||
<P><I>Use, modification and distribution are subject to the Boost Software License,
|
||||
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
|
||||
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
|
||||
|
||||
@@ -38,15 +38,15 @@
|
||||
<PRE><B>template</B> <<B>class</B> OutputIterator, <B>class</B> charT, <B>class</B> Traits1, <B>class</B> Alloc1, <B>class</B> Traits2, <B>class</B> Alloc2>
|
||||
std::size_t regex_split(OutputIterator out,
|
||||
std::basic_string<charT, Traits1, Alloc1>& s,
|
||||
<B> const</B> basic_regex<charT, Traits2, Alloc2>& e,
|
||||
<B> unsigned</B> flags,
|
||||
<B> const</B> basic_regex<charT, Traits2, Alloc2>& e,
|
||||
<STRONG> </STRONG>boost::match_flag_type flags,
|
||||
std::size_t max_split);
|
||||
|
||||
<B>template</B> <<B>class</B> OutputIterator, <B>class</B> charT, <B>class</B> Traits1, <B>class</B> Alloc1, <B>class</B> Traits2, <B>class</B> Alloc2>
|
||||
std::size_t regex_split(OutputIterator out,
|
||||
std::basic_string<charT, Traits1, Alloc1>& s,
|
||||
<B> const</B> basic_regex<charT, Traits2, Alloc2>& e,
|
||||
<B>unsigned</B> flags = match_default);
|
||||
<B> const</B> basic_regex<charT, Traits2, Alloc2>& e,
|
||||
boost::match_flag_type flags = match_default);
|
||||
|
||||
<B>template</B> <<B>class</B> OutputIterator, <B>class</B> charT, <B>class</B> Traits1, <B>class</B> Alloc1>
|
||||
std::size_t regex_split(OutputIterator out,
|
||||
@@ -134,11 +134,10 @@ boost::regex e(<FONT color=#000080>"<\\s*A\\s+[^>]*href\\s*=\\s*\"([^\"]*)
|
||||
<HR>
|
||||
<p>Revised
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
|
||||
24 Oct 2003
|
||||
04 Feb 2004
|
||||
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
|
||||
<p><i>© Copyright John Maddock 1998-
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
|
||||
2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2004<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||
<P><I>Use, modification and distribution are subject to the Boost Software License,
|
||||
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
|
||||
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
|
||||
|
||||
@@ -76,7 +76,7 @@ typedef regex_token_iterator<const char*> cregex_token_i
|
||||
typedef regex_token_iterator<std::string::const_iterator> sregex_token_iterator;
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator;
|
||||
typedef regex_token_iterator<<std::wstring::const_iterator> wsregex_token_iterator;
|
||||
typedef regex_token_iterator<<std::wstring::const_iterator> wsregex_token_iterator;
|
||||
#endif
|
||||
</PRE>
|
||||
<H3><A name="description"></A>Description</H3>
|
||||
@@ -84,7 +84,8 @@ typedef regex_token_iterator<<std::wstring::const_iterator> wsregex_token_
|
||||
<P><B> Effects:</B> constructs an end of sequence iterator.</P>
|
||||
<PRE><A name=c2></A>regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re,
|
||||
int submatch = 0, match_flag_type m = match_default);</PRE>
|
||||
<P><B> Preconditions: </B><CODE>!re.empty()</CODE>.</P>
|
||||
<P><B> Preconditions: </B><CODE>!re.empty()</CODE>. Object re shall exist
|
||||
for the lifetime of the iterator constructed from it.</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>. The
|
||||
@@ -99,7 +100,8 @@ typedef regex_token_iterator<<std::wstring::const_iterator> wsregex_token_
|
||||
configured</A> in non-recursive mode).</P>
|
||||
<PRE><A name=c3></A>regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re,
|
||||
const std::vector<int>& submatches, match_flag_type m = match_default);</PRE>
|
||||
<P><B> Preconditions:</B> <CODE>submatches.size() && !re.empty()</CODE>.</P>
|
||||
<P><B> Preconditions:</B> <CODE>submatches.size() && !re.empty()</CODE>.
|
||||
Object re shall exist for the lifetime of the iterator constructed from it.</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>. For
|
||||
@@ -118,7 +120,8 @@ typedef regex_token_iterator<<std::wstring::const_iterator> wsregex_token_
|
||||
<PRE><A name=c4></A>template <std::size_t N>
|
||||
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, const regex_type& re,
|
||||
const int (&submatches)[R], match_flag_type m = match_default);</PRE>
|
||||
<P><B> Preconditions: </B><CODE>!re.empty()</CODE>.</P>
|
||||
<P><B> Preconditions: </B><CODE>!re.empty()</CODE>. Object re shall exist
|
||||
for the lifetime of the iterator constructed from it.</P>
|
||||
<P><STRONG>Effects:</STRONG></B> constructs a regex_token_iterator that will
|
||||
enumerate <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
|
||||
|
||||
@@ -24,10 +24,12 @@
|
||||
</P>
|
||||
<HR>
|
||||
<p></p>
|
||||
<P>Under construction.</P>
|
||||
<P>The current boost.regex traits class design will be migrated to that specified
|
||||
in the <A href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1429.htm">regular
|
||||
expression standardization proposal</A>. </P>
|
||||
<P>
|
||||
Under construction: the current design will be replaced by that specified in
|
||||
the <A href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1429.htm">regular
|
||||
expression standardization proposal</A>, the current (obsolete) design has
|
||||
it's <A href="http://cvs.sourceforge.net/viewcvs.py/*checkout*/boost/boost/libs/regex/Attic/traits_class_ref.htm?rev=1.11">
|
||||
documentation archived online</A>.</P>
|
||||
<P>
|
||||
<HR>
|
||||
<P></P>
|
||||
@@ -36,11 +38,9 @@
|
||||
24 Oct 2003
|
||||
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
|
||||
<p><i>© Copyright John Maddock 1998-
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
|
||||
2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||
<P><I>Use, modification and distribution are subject to the Boost Software License,
|
||||
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
|
||||
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+98
-101
@@ -91,18 +91,18 @@
|
||||
<P>Parentheses serve two purposes, to group items together into a sub-expression,
|
||||
and to mark what generated the match. For example the expression "(ab)*" would
|
||||
match all of the string "ababab". The matching algorithms <A href="regex_match.html">
|
||||
regex_match</A> and <A href="regex_search.html">regex_search</A>
|
||||
each take an instance of <A href="match_results.html">match_results</A>
|
||||
that reports what caused the match, on exit from these functions the <A href="match_results.html">
|
||||
match_results</A> contains information both on what the whole expression
|
||||
matched and on what each sub-expression matched. In the example above
|
||||
match_results[1] would contain a pair of iterators denoting the final "ab" of
|
||||
the matching string. It is permissible for sub-expressions to match null
|
||||
strings. If a sub-expression takes no part in a match - for example if it is
|
||||
part of an alternative that is not taken - then both of the iterators that are
|
||||
returned for that sub-expression point to the end of the input string, and the <I>matched</I>
|
||||
parameter for that sub-expression is <I>false</I>. Sub-expressions are indexed
|
||||
from left to right starting from 1, sub-expression 0 is the whole expression.
|
||||
regex_match</A> and <A href="regex_search.html">regex_search</A> each take
|
||||
an instance of <A href="match_results.html">match_results</A> that reports what
|
||||
caused the match, on exit from these functions the <A href="match_results.html">match_results</A>
|
||||
contains information both on what the whole expression matched and on what each
|
||||
sub-expression matched. In the example above match_results[1] would contain a
|
||||
pair of iterators denoting the final "ab" of the matching string. It is
|
||||
permissible for sub-expressions to match null strings. If a sub-expression
|
||||
takes no part in a match - for example if it is part of an alternative that is
|
||||
not taken - then both of the iterators that are returned for that
|
||||
sub-expression point to the end of the input string, and the <I>matched</I> parameter
|
||||
for that sub-expression is <I>false</I>. Sub-expressions are indexed from left
|
||||
to right starting from 1, sub-expression 0 is the whole expression.
|
||||
</P>
|
||||
<H3>Non-Marking Parenthesis
|
||||
</H3>
|
||||
@@ -143,7 +143,7 @@
|
||||
<P>A set is a set of characters that can match any single character that is a
|
||||
member of the set. Sets are delimited by "[" and "]" and can contain literals,
|
||||
character ranges, character classes, collating elements and equivalence
|
||||
classes. Set declarations that start with "^" contain the compliment of the
|
||||
classes. Set declarations that start with "^" contain the complement of the
|
||||
elements that follow.
|
||||
</P>
|
||||
<P>Examples:
|
||||
@@ -293,7 +293,7 @@
|
||||
[^[.ae.]] would only match one character.
|
||||
</P>
|
||||
<P>
|
||||
Equivalence classes take the general form[=tagname=] inside a set declaration,
|
||||
Equivalence classes take the generalform[=tagname=] inside a set declaration,
|
||||
where <I>tagname</I> is either a single character, or a name of a collating
|
||||
element, and matches any character that is a member of the same primary
|
||||
equivalence class as the collating element [.tagname.]. An equivalence class is
|
||||
@@ -302,7 +302,7 @@
|
||||
typically collated by character, then by accent, and then by case; the primary
|
||||
sort key then relates to the character, the secondary to the accentation, and
|
||||
the tertiary to the case). If there is no equivalence class corresponding to <I>tagname</I>
|
||||
, then[=tagname=] is exactly the same as [.tagname.]. Unfortunately there is no
|
||||
,then[=tagname=] is exactly the same as [.tagname.]. Unfortunately there is no
|
||||
locale independent method of obtaining the primary sort key for a character,
|
||||
except under Win32. For other operating systems the library will "guess" the
|
||||
primary sort key from the full sort key (obtained from <I>strxfrm</I>), so
|
||||
@@ -666,106 +666,103 @@
|
||||
<H3>What gets matched?
|
||||
</H3>
|
||||
<P>
|
||||
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.</P>
|
||||
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.</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
|
||||
string starting at a given location can match then it matches the longest
|
||||
possible string, unless the flag match_any is set, in which case the first
|
||||
match encountered is returned. Use of the match_any option can reduce the time
|
||||
taken to find the match - but is only useful if the user is less concerned
|
||||
about what matched - for example it would not be suitable for search and
|
||||
replace operations. In cases where their are multiple possible matches all
|
||||
starting at the same location, and all of the same length, then the match
|
||||
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
|
||||
POSIX regular expression matching rules:
|
||||
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
|
||||
string starting at a given location can match then it matches the longest
|
||||
possible string, unless the flag match_any is set, in which case the first
|
||||
match encountered is returned. Use of the match_any option can reduce the time
|
||||
taken to find the match - but is only useful if the user is less concerned
|
||||
about what matched - for example it would not be suitable for search and
|
||||
replace operations. In cases where their are multiple possible matches all
|
||||
starting at the same location, and all of the same length, then the match
|
||||
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>
|
||||
<TABLE id="Table5" cellSpacing="1" cellPadding="7" width="624" border="1">
|
||||
<TBODY>
|
||||
<TR>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P>Expression</P>
|
||||
</TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P>Text</P>
|
||||
</TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P>POSIX leftmost longest match</P>
|
||||
</TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P>ECMAScript depth first search match</P>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE>a|ab</CODE></P>
|
||||
</TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE>
|
||||
xaby</CODE>
|
||||
The following table examples illustrate the main differences between Perl and
|
||||
POSIX regular expression matching rules:
|
||||
</P>
|
||||
</TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE>
|
||||
"ab"</CODE></P></TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE>
|
||||
"a"</CODE></P></TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE>
|
||||
.*([[:alnum:]]+).*</CODE></P></TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE>
|
||||
" abc def xyz "</CODE></P></TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P>$0 = " abc def xyz "<BR>
|
||||
$1 = "abc"</P>
|
||||
</TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P>$0 = " abc def xyz "<BR>
|
||||
$1 = "z"</P>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE>
|
||||
.*(a|xayy)</CODE></P></TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE>
|
||||
zzxayyzz</CODE></P></TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE>
|
||||
"zzxayy"</CODE></P></TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE>"zzxa"</CODE></P>
|
||||
</TD>
|
||||
</TR>
|
||||
</TBODY></CODE></TD></TR></TABLE>
|
||||
<P>
|
||||
<TABLE id="Table5" cellSpacing="1" cellPadding="7" width="624" border="1">
|
||||
<TBODY>
|
||||
<TR>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P>Expression</P>
|
||||
</TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P>Text</P>
|
||||
</TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P>POSIX leftmost longest match</P>
|
||||
</TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P>ECMAScript depth first search match</P>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE>a|ab</CODE></P>
|
||||
</TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE> xaby</CODE>
|
||||
</P>
|
||||
</TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE> "ab"</CODE></P>
|
||||
</TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE> "a"</CODE></P>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE> .*([[:alnum:]]+).*</CODE></P>
|
||||
</TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE> " abc def xyz "</CODE></P>
|
||||
</TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P>$0 = " abc def xyz "<BR>
|
||||
$1 = "abc"</P>
|
||||
</TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P>$0 = " abc def xyz "<BR>
|
||||
$1 = "z"</P>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE> .*(a|xayy)</CODE></P>
|
||||
</TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE> zzxayyzz</CODE></P>
|
||||
</TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE> "zzxayy"</CODE></P>
|
||||
</TD>
|
||||
<TD vAlign="top" width="25%">
|
||||
<P><CODE>"zzxa"</CODE></P>
|
||||
</TD>
|
||||
</TR>
|
||||
</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.</p>
|
||||
<HR>
|
||||
algorithms used to traverse the state machine.</P>
|
||||
<HR>
|
||||
<p>Revised
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
|
||||
24 Oct 2003
|
||||
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
|
||||
<p><i>© Copyright John Maddock 1998-
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
|
||||
2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||
<P><I>Use, modification and distribution are subject to the Boost Software License,
|
||||
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
|
||||
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
+10
-11
@@ -24,13 +24,15 @@
|
||||
</P>
|
||||
<HR>
|
||||
<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. For convenience
|
||||
note that all the constants listed here, are also duplicated within the scope
|
||||
of class template <A href="basic_regex.html">basic_regex</A>.</P>
|
||||
<P>Type syntax_option type is an implementation specific bitmask type that
|
||||
controls how a regular expression string is to be interpreted. For
|
||||
convenience note that all the constants listed here, are also duplicated within
|
||||
the scope of class template <A href="basic_regex.html">basic_regex</A>.</P>
|
||||
<PRE>namespace std{ namespace regex_constants{
|
||||
|
||||
typedef bitmask_type syntax_option_type;
|
||||
typedef <EM>implementation-specific-bitmask-type</EM>
|
||||
|
||||
syntax_option_type;
|
||||
// these flags are standardized:
|
||||
static const syntax_option_type normal;
|
||||
static const syntax_option_type icase;
|
||||
@@ -50,7 +52,7 @@ static const syntax_option_type perl;<BR>// these are boost.regex specific:<BR>s
|
||||
} // namespace regex_constants
|
||||
} // namespace std</PRE>
|
||||
<H3>Description</H3>
|
||||
<P>The type <CODE>syntax_option_type</CODE> is an implementation defined bitmask
|
||||
<P>The type <CODE>syntax_option_type</CODE> is an implementation specific bitmask
|
||||
type (17.3.2.1.2). Setting its elements has the effects listed in the table
|
||||
below, a valid value of type <CODE>syntax_option_type</CODE> will always have
|
||||
exactly one of the elements <CODE>normal, basic, extended, awk, grep, egrep, sed
|
||||
@@ -314,18 +316,15 @@ static const syntax_option_type perl;<BR>// these are boost.regex specific:<BR>s
|
||||
</TR>
|
||||
</TABLE>
|
||||
</P>
|
||||
<HR>
|
||||
<HR>
|
||||
<p>Revised
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
|
||||
24 Oct 2003
|
||||
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
|
||||
<p><i>© Copyright John Maddock 1998-
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
|
||||
2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||
<P><I>Use, modification and distribution are subject to the Boost Software License,
|
||||
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
|
||||
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
Reference in new issue
Block a user