Added new docs,

Moved source more into line with the std lib proposal.


[SVN r18292]
This commit is contained in:
John Maddock
2003-04-23 10:49:57 +00:00
parent c233f06654
commit c8f2ed3bdb
111 changed files with 17582 additions and 7758 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,77 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: bad_expression</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">class bad_expression</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<H3>Synopsis</H3>
<P>#include &lt;<A href="../../boost/regex/pattern_except.hpp">boost/pat_except.hpp</A>&gt;
</P>
<P>The class <CODE>bad_expression</CODE> defines the type of objects thrown as
exceptions to report errors during the conversion from a string representing a
regular expression to a finite state machine.&nbsp;&nbsp;</P>
<PRE><B>namespace</B> boost{
<B>class</B> bad_pattern : <B>public</B> std::runtime_error
{
<B>public</B>:
&nbsp;&nbsp; <B>explicit</B> bad_pattern(<B>const</B> std::string&amp; s) : std::runtime_error(s){};
};
<B>class</B> bad_expression : <B>public</B> bad_pattern
{
<B>public</B>:
&nbsp;&nbsp; bad_expression(<B>const</B> std::string&amp; s) : bad_pattern(s) {}
};
} // namespace boost</PRE>
<H3>Description</H3>
<PRE>bad_expression(const string&amp; what_arg); </PRE>
<P><B>Effects:</B> Constructs an object of class <CODE>bad_expression</CODE>.</P>
<B>
<P>
Postcondition:</B> <CODE>strcmp(what(), what_arg.c_str()) == 0</CODE>.
<P>Footnotes: the class <I>bad_pattern </I>forms the base class for all
pattern-matching exceptions, of which <I>bad_expression</I> is one. The choice
of <I>std::runtime_error </I>as the base class for <I>bad_pattern</I>
is moot, depending upon how the library is used exceptions may be either logic
errors (programmer supplied expressions) or run time errors (user supplied
expressions).
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

944
doc/Attic/basic_regex.html Normal file
View File

@ -0,0 +1,944 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: basic_regex</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">basic_regex</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<H3>Synopsis</H3>
<PRE>#include &lt;<A href="../../boost/regex.hpp">boost/regex.hpp</A>&gt; </PRE>
<P>The template class <EM>basic_regex </EM>encapsulates regular expression parsing
and compilation. The class takes three template parameters:
</P>
<P><B><I>charT</I></B>: determines the character type, i.e. either char or
wchar_t.
</P>
<P><B><I>traits</I></B>: determines the behaviour of the character type, for
example which character class names are recognized. A default traits class is
provided: <A href="regex_traits.html">regex_traits&lt;charT&gt;</A>.
</P>
<P><B><I>Allocator</I></B>: the allocator class used to allocate memory by the
class.
</P>
<P>For ease of use there are two typedefs that define the two standard <I>basic_regex </I>
instances, unless you want to use custom traits classes or allocators, you
won't need to use anything other than these:
</P>
<PRE><B>namespace</B> boost{
<B>template</B> &lt;<B>class</B> charT, <B>class</B> traits = regex_traits&lt;charT&gt;, <B>class</B> Allocator = std::allocator&lt;charT&gt;&nbsp; &gt;
<B>class</B> reg_expression;
<B>typedef</B> reg_expression&lt;<B>char</B>&gt; regex;
<B>typedef</B> reg_expression&lt;<B>wchar_t&gt; </B>wregex;
}</PRE>
<P>The definition of <I>reg_expression</I> follows: it is based very closely on
class basic_string, and fulfils the requirements for a constant-container of <I>charT</I>.
</P>
<PRE>namespace boost{
template &lt;class charT,
class traits = regex_traits&lt;charT&gt;,
class Allocator = allocator&lt;charT&gt; &gt;
class basic_regex
{
public:
// types:
typedef charT value_type;
typedef implementation defined const_iterator;
typedef const_iterator iterator;
typedef typename Allocator::reference reference;
typedef typename Allocator::const_reference const_reference;
typedef typename Allocator::difference_type difference_type;
typedef typename Allocator::size_type size_type;
typedef Allocator allocator_type;
typedef regex_constants::syntax_option_type flag_type;
typedef typename traits::locale_type locale_type;
// constants:
static const regex_constants::syntax_option_type normal = regex_constants::normal;
static const regex_constants::syntax_option_type icase = regex_constants::icase;
static const regex_constants::syntax_option_type nosubs = regex_constants::nosubs;
static const regex_constants::syntax_option_type optimize = regex_constants::optimize;
static const regex_constants::syntax_option_type collate = regex_constants::collate;
static const regex_constants::syntax_option_type ECMAScript = normal;
static const regex_constants::syntax_option_type JavaScript = normal;
static const regex_constants::syntax_option_type JScript = normal;
// these flags are optional, if the functionality is supported
// then the flags shall take these names.
static const regex_constants::syntax_option_type basic = regex_constants::basic;
static const regex_constants::syntax_option_type extended = regex_constants::extended;
static const regex_constants::syntax_option_type awk = regex_constants::awk;
static const regex_constants::syntax_option_type grep = regex_constants::grep;
static const regex_constants::syntax_option_type egrep = regex_constants::egrep;
static const regex_constants::syntax_option_type sed = basic = regex_constants::sed;
static const regex_constants::syntax_option_type perl = regex_constants::perl;
// construct/copy/destroy:
explicit basic_regex(const Allocator&amp; a = Allocator());
explicit basic_regex(const charT* p, flag_type f = regex_constants::normal,
const Allocator&amp; a = Allocator());
basic_regex(const charT* p1, const charT* p2, flag_type f = regex_constants::normal,
const Allocator&amp; a = Allocator());
basic_regex(const charT* p, size_type len, flag_type f,
const Allocator&amp; a = Allocator());
basic_regex(const basic_regex&amp;);
template &lt;class ST, class SA&gt;
explicit basic_regex(const basic_string&lt;charT, ST, SA&gt;&amp; p,
flag_type f = regex_constants::normal,
const Allocator&amp; a = Allocator());
template &lt;class InputIterator&gt;
basic_regex(InputIterator first, inputIterator last,
flag_type f = regex_constants::normal,
const Allocator&amp; a = Allocator());
~basic_regex();
basic_regex&amp; operator=(const basic_regex&amp;);
basic_regex&amp; operator=(const charT* ptr);
template &lt;class ST, class SA&gt;
basic_regex&amp; operator=(const basic_string&lt;charT, ST, SA&gt;&amp; p);
// iterators:
const_iterator begin() const;
const_iterator end() const;
// capacity:
size_type size() const;
size_type max_size() const;
bool empty() const;
unsigned mark_count() const;
//
// modifiers:
basic_regex&amp; assign(const basic_regex&amp; that);
basic_regex&amp; assign(const charT* ptr, flag_type f = regex_constants::normal);
basic_regex&amp; assign(const charT* first, const charT* last,
flag_type f = regex_constants::normal);
template &lt;class string_traits, class A&gt;
basic_regex&amp; assign(const basic_string&lt;charT, string_traits, A&gt;&amp; s,
flag_type f = regex_constants::normal);
template &lt;class InputIterator&gt;
basic_regex&amp; assign(InputIterator first, InputIterator last,
flag_type f = regex_constants::normal);
// const operations:
Allocator get_allocator() const;
flag_type getflags() const;
basic_string&lt;charT&gt; str() const;
int compare(basic_regex&amp;) const;
// locale:
locale_type imbue(locale_type loc);
locale_type getloc() const;
// swap
void swap(basic_regex&amp;) throw();
};
template &lt;class charT, class traits, class Allocator&gt;
bool operator == (const basic_regex&lt;charT, traits, Allocator&gt;&amp; lhs,
const basic_regex&lt;charT, traits, Allocator&gt;&amp; rhs);
template &lt;class charT, class traits, class Allocator&gt;
bool operator != (const basic_regex&lt;charT, traits, Allocator&gt;&amp; lhs,
const basic_regex&lt;charT, traits, Allocator&gt;&amp; rhs);
template &lt;class charT, class traits, class Allocator&gt;
bool operator &lt; (const basic_regex&lt;charT, traits, Allocator&gt;&amp; lhs,
const basic_regex&lt;charT, traits, Allocator&gt;&amp; rhs);
template &lt;class charT, class traits, class Allocator&gt;
bool operator &lt;= (const basic_regex&lt;charT, traits, Allocator&gt;&amp; lhs,
const basic_regex&lt;charT, traits, Allocator&gt;&amp; rhs);
template &lt;class charT, class traits, class Allocator&gt;
bool operator &gt;= (const basic_regex&lt;charT, traits, Allocator&gt;&amp; lhs,
const basic_regex&lt;charT, traits, Allocator&gt;&amp; rhs);
template &lt;class charT, class traits, class Allocator&gt;
bool operator &gt; (const basic_regex&lt;charT, traits, Allocator&gt;&amp; lhs,
const basic_regex&lt;charT, traits, Allocator&gt;&amp; rhs);
template &lt;class charT, class io_traits, class re_traits, class Allocator&gt;
basic_ostream&lt;charT, io_traits&gt;&amp;
operator &lt;&lt; (basic_ostream&lt;charT, io_traits&gt;&amp; os,
const basic_regex&lt;charT, re_traits, Allocator&gt;&amp; e);
template &lt;class charT, class traits, class Allocator&gt;
void swap(basic_regex&lt;charT, traits, Allocator&gt;&amp; e1,
basic_regex&lt;charT, traits, Allocator&gt;&amp; e2);
typedef basic_regex&lt;char&gt; regex;
typedef basic_regex&lt;wchar_t&gt; wregex;
} // namespace boost</PRE>
<H3>Description</H3>
<P>Class&nbsp;<EM>basic_regex</EM> has the following public member functions:
</P>
<H4>basic_regex constants</H4>
<PRE>static const regex_constants::syntax_option_type normal = regex_constants::normal;
static const regex_constants::syntax_option_type icase = regex_constants::icase;
static const regex_constants::syntax_option_type nosubs = regex_constants::nosubs;
static const regex_constants::syntax_option_type optimize = regex_constants::optimize;
static const regex_constants::syntax_option_type collate = regex_constants::collate;
static const regex_constants::syntax_option_type ECMAScript = normal;
static const regex_constants::syntax_option_type JavaScript = normal;
static const regex_constants::syntax_option_type JScript = normal;
static const regex_constants::syntax_option_type basic = regex_constants::basic;
static const regex_constants::syntax_option_type extended = regex_constants::extended;
static const regex_constants::syntax_option_type awk = regex_constants::awk;
static const regex_constants::syntax_option_type grep = regex_constants::grep;
static const regex_constants::syntax_option_type egrep = regex_constants::egrep;
static const regex_constants::syntax_option_type sed = basic = regex_constants::sed;
static const regex_constants::syntax_option_type perl = regex_constants::perl;</PRE>
<P>The static constant members are provided as synonyms for the constants declared
in namespace <CODE>boost::regex_constants</CODE>; for each constant of type <CODE>syntax_option_type</CODE>
declared in namespace <CODE>boost::regex_constants</CODE> then a constant with
the same name, type and value is declared within the scope of <CODE>basic_regex</CODE>.</P>
<H4>basic_regex constructors</H4>
<P>In all <CODE>basic_regex</CODE> constructors, a copy of the <CODE>Allocator</CODE>
argument is used for any memory allocation performed by the constructor or
member functions during the lifetime of the object.
</P>
<PRE>basic_regex(const Allocator&amp; a = Allocator());</PRE>
<B>
<P>
Effects:</B> Constructs an object of class <CODE>basic_regex</CODE>. The
postconditions of this function are indicated in the table:<I></I><I></P>
<P>
<DIV align="center">
<P></P>
</I>
<P align="center">
<CENTER>
<TABLE id="Table2" cellSpacing="1" cellPadding="7" width="624" border="1">
<TBODY>
<TR>
<TD vAlign="top" width="50%"><B>
<P>
Element</B>
</P>
</TD>
<TD vAlign="top" width="50%"><B>
<P>
Value </B></P></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>empty()</P>
</TD>
<TD vAlign="top" width="50%">
<P>true</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>size()</P>
</TD>
<TD vAlign="top" width="50%">
<P>0</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>str()</P>
</TD>
<TD vAlign="top" width="50%">
<P>basic_string&lt;charT&gt;()</P>
<P></P>
</TD>
</TR>
</TBODY></TD></TR></TABLE></CENTER>
<P></P>
</DIV><PRE>basic_regex(const charT* p, flag_type f = regex_constants::normal, const Allocator&amp; a = Allocator());</PRE>
<B>
<P>
Requires:</B> <I>p</I> shall not be a null pointer.</P><B>
<P>
Throws: </B><CODE>bad_expression</CODE> if <I>p</I> is not a valid regular
expression.</P><B>
<P>
Effects:</B> Constructs an object of class <CODE>basic_regex</CODE>; the
object's internal finite state machine is constructed from the regular
expression contained in the null-terminated string <I>p</I>, and interpreted
according to the <A href="syntax_option_type.html">option flags</A>&nbsp;specified
in <I>f</I>. The postconditions of this function are indicated in the
table:</P><I>
<P>
<DIV align="center">
<P></P>
</I>
<P align="center">
<CENTER>
<TABLE id="Table3" cellSpacing="1" cellPadding="7" width="624" border="1">
<TBODY>
<TR>
<TD vAlign="top" width="50%"><B>
<P>
Element</B>
</P>
</TD>
<TD vAlign="top" width="50%"><B>
<P>
Value</B> </P></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>empty()</P>
</TD>
<TD vAlign="top" width="50%">
<P>false</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>size()</P>
</TD>
<TD vAlign="top" width="50%">
<P>char_traits&lt;charT&gt;::length(p)</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>str()</P>
</TD>
<TD vAlign="top" width="50%">
<P>basic_string&lt;charT&gt;(p)</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>getflags()</P>
</TD>
<TD vAlign="top" width="50%">
<P>f</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>mark_count()</P>
</TD>
<TD vAlign="top" width="50%">
<P>The number of marked sub-expressions within the expression.</P>
<P></P>
</TD>
</TR>
</TBODY></TD></TR></TABLE></CENTER>
<P></P>
</DIV><PRE>basic_regex(const charT* p1, const charT* p2, flag_type f = regex_constants::normal, const Allocator&amp; a = Allocator());</PRE>
<B>
<P>
Requires:</B> <I>p1 </I>and<I> p2</I> are not null pointers, <CODE>p1 &lt; p2</CODE>.</P><B>
<P>
Throws: </B><CODE>bad_expression</CODE> if [p1,p2) is not a valid regular
expression.</P><B>
<P>
Effects:</B> Constructs an object of class <CODE>basic_regex</CODE>; the
object's internal finite state machine is constructed from the regular
expression contained in the sequence of characters [p1,p2), and interpreted
according the <A href="syntax_option_type.html">option flags</A> specified in <I>f</I>.
The postconditions of this function are indicated in the table:</P><I>
<P>
<DIV align="center">
<P></P>
</I>
<P align="center">
<CENTER>
<TABLE id="Table4" cellSpacing="1" cellPadding="7" width="624" border="1">
<TBODY>
<TR>
<TD vAlign="top" width="50%"><B>
<P>
Element</B>
</P>
</TD>
<TD vAlign="top" width="50%"><B>
<P>
Value</B> </P></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>empty()</P>
</TD>
<TD vAlign="top" width="50%">
<P>false</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>size()</P>
</TD>
<TD vAlign="top" width="50%">
<P>std::distance(p1,p2)</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>str()</P>
</TD>
<TD vAlign="top" width="50%">
<P>basic_string&lt;charT&gt;(p1,p2)</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>getflags()</P>
</TD>
<TD vAlign="top" width="50%">
<P>f</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>mark_count()</P>
</TD>
<TD vAlign="top" width="50%">
<P>The number of marked sub-expressions within the expression.</P>
<P></P>
</TD>
</TR>
</TBODY></TD></TR></TABLE></CENTER>
<P></P>
</DIV><PRE>basic_regex(const charT* p, size_type len, flag_type f, const Allocator&amp; a = Allocator());</PRE>
<B>
<P>
Requires:</B> <I>p</I> shall not be a null pointer, <CODE>len &lt; max_size()</CODE>.</P><B>
<P>
Throws: </B><CODE>bad_expression</CODE> if <I>p</I> is not a valid regular
expression.</P><B>
<P>
Effects:</B> Constructs an object of class <CODE>basic_regex</CODE>; the
object's internal finite state machine is constructed from the regular
expression contained in the sequence of characters [p, p+len), and interpreted
according the <A href="syntax_option_type.html">option flags </A>specified in <I>f</I>.
The postconditions of this function are indicated in the table:</P><I>
<P>
<DIV align="center">
<P></P>
</I>
<P align="center">
<CENTER>
<TABLE id="Table5" cellSpacing="1" cellPadding="7" width="624" border="1">
<TBODY>
<TR>
<TD vAlign="top" width="50%"><B>
<P>
Element</B>
</P>
</TD>
<TD vAlign="top" width="50%"><B>
<P>
Value</B> </P></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>empty()</P>
</TD>
<TD vAlign="top" width="50%">
<P>false</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>size()</P>
</TD>
<TD vAlign="top" width="50%">
<P>len</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>str()</P>
</TD>
<TD vAlign="top" width="50%">
<P>basic_string&lt;charT&gt;(p, len)</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>getflags()</P>
</TD>
<TD vAlign="top" width="50%">
<P>f</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>mark_count()</P>
</TD>
<TD vAlign="top" width="50%">
<P>The number of marked sub-expressions within the expression.</P>
<P></P>
</TD>
</TR>
</TBODY></TD></TR></TABLE></CENTER>
<P></P>
</DIV><PRE>basic_regex(const basic_regex&amp; e);</PRE>
<B>
<P>
Effects:</B> Constructs an object of class <CODE>basic_regex</CODE> as a
copy of the object <I>e</I>. The postconditions of this function are indicated
in the table:</P><I>
<P>
<DIV align="center">
<P></P>
</I>
<P align="center">
<CENTER>
<TABLE id="Table6" cellSpacing="1" cellPadding="7" width="624" border="1">
<TBODY>
<TR>
<TD vAlign="top" width="50%"><B>
<P>
Element</B>
</P>
</TD>
<TD vAlign="top" width="50%"><B>
<P>
Value</B> </P></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>empty()</P>
</TD>
<TD vAlign="top" width="50%">
<P>e.empty()</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>size()</P>
</TD>
<TD vAlign="top" width="50%">
<P>e.size()</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>str()</P>
</TD>
<TD vAlign="top" width="50%">
<P>e.str()</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>getflags()</P>
</TD>
<TD vAlign="top" width="50%">
<P>e.getflags()</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>mark_count()</P>
</TD>
<TD vAlign="top" width="50%">
<P>e.mark_count()</P>
<P></P>
</TD>
</TR>
</TBODY></TD></TR></TABLE></CENTER>
<P></P>
</DIV><PRE>template &lt;class ST, class SA&gt;
basic_regex(const basic_string&lt;charT, ST, SA&gt;&amp; s,
flag_type f = regex_constants::normal, const Allocator&amp; a = Allocator());</PRE>
<B>
<P>
Throws: </B><CODE>bad_expression</CODE> if <I>s</I> is not a valid regular
expression.</P><B>
<P>
Effects:</B> Constructs an object of class <CODE>basic_regex</CODE>; the
object's internal finite state machine is constructed from the regular
expression contained in the string <I>s</I>, and interpreted according to the <A href="syntax_option_type.html">
option flags </A>specified in <I>f</I>. The postconditions of this function
are indicated in the table:</P><I>
<P>
<DIV align="center">
<P></P>
</I>
<P align="center">
<CENTER>
<TABLE id="Table7" cellSpacing="1" cellPadding="7" width="624" border="1">
<TBODY>
<TR>
<TD vAlign="top" width="50%"><B>
<P>
Element</B>
</P>
</TD>
<TD vAlign="top" width="50%"><B>
<P>
Value</B> </P></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>empty()</P>
</TD>
<TD vAlign="top" width="50%">
<P>false</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>size()</P>
</TD>
<TD vAlign="top" width="50%">
<P>s.size()</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>str()</P>
</TD>
<TD vAlign="top" width="50%">
<P>s</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>getflags()</P>
</TD>
<TD vAlign="top" width="50%">
<P>f</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>mark_count()</P>
</TD>
<TD vAlign="top" width="50%">
<P>The number of marked sub-expressions within the expression.</P>
<P></P>
</TD>
</TR>
</TBODY></TD></TR></TABLE></CENTER>
<P></P>
</DIV><PRE>template &lt;class ForwardIterator&gt;
basic_regex(ForwardIterator first, ForwardIterator last,
flag_type f = regex_constants::normal, const Allocator&amp; a = Allocator());</PRE>
<B>
<P>
Throws: </B><CODE>bad_expression</CODE> if the sequence <I>[first, last)</I>
is not a valid regular expression.</P><B>
<P>
Effects:</B> Constructs an object of class <CODE>basic_regex</CODE>; the
object's internal finite state machine is constructed from the regular
expression contained in the sequence of characters [first, last), and
interpreted according to the <A href="syntax_option_type.html">option flags </A>
specified in <I>f</I>. The postconditions of this function are indicated in the
table:</P><I>
<P>
<DIV align="center">
<P></P>
</I>
<P align="center">
<CENTER>
<TABLE id="Table8" cellSpacing="1" cellPadding="7" width="624" border="1">
<TBODY>
<TR>
<TD vAlign="top" width="50%"><B>
<P>
Element</B>
</P>
</TD>
<TD vAlign="top" width="50%"><B>
<P>
Value</B> </P></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>empty()</P>
</TD>
<TD vAlign="top" width="50%">
<P>false</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>size()</P>
</TD>
<TD vAlign="top" width="50%">
<P>distance(first,last)</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>str()</P>
</TD>
<TD vAlign="top" width="50%">
<P>basic_string&lt;charT&gt;(first,last)</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>getflags()</P>
</TD>
<TD vAlign="top" width="50%">
<P>f</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>mark_count()</P>
</TD>
<TD vAlign="top" width="50%">
<P>The number of marked sub-expressions within the expression.</P>
<P></P>
</TD>
</TR>
</TBODY></TD></TR></TABLE></CENTER>
<P></P>
</DIV><PRE>basic_regex&amp; operator=(const basic_regex&amp; e);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>assign(e.str(), e.getflags())</CODE>.</P><PRE>basic_regex&amp; operator=(const charT* ptr);</PRE>
<B>
<P>
Requires:</B> <I>p</I> shall not be a null pointer.</P><B>
<P>
Effects:</B> Returns the result of <CODE>assign(ptr)</CODE>.</P><PRE>template &lt;class ST, class SA&gt;
basic_regex&amp; operator=(const basic_string&lt;charT, ST, SA&gt;&amp; p);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>assign(p)</CODE>.</P>
<H4>basic_regex iterators</H4>
<PRE>const_iterator begin() const;</PRE>
<B>
<P>
Effects:</B> Returns a starting iterator to a sequence of characters
representing the regular expression.</P><PRE>const_iterator end() const;</PRE>
<B>
<P>
Effects:</B> Returns termination iterator to a sequence of characters
representing the regular expression.</P>
<H4>basic_regex capacity</H4>
<PRE>size_type size() const;</PRE>
<B>
<P>
Effects:</B> Returns the length of the sequence of characters representing
the regular expression.</P><PRE>size_type max_size() const;</PRE>
<B>
<P>
Effects:</B> Returns the maximum length of the sequence of characters
representing the regular expression.</P><PRE>bool empty() const;</PRE>
<B>
<P>
Effects:</B> Returns <B>true</B> if the object does not contain a valid
regular expression, otherwise <B>false</B>.</P><PRE>unsigned mark_count() const;</PRE>
<B>
<P>
Effects:</B> Returns the number of marked sub-expressions within the regular
expresion.</P>
<H4>basic_regex assign</H4>
<PRE>basic_regex&amp; assign(const basic_regex&amp; that);</PRE>
<B>
<P>
Effects:</B> Returns <CODE>assign(that.str(), that.getflags())</CODE>.</P><PRE>basic_regex&amp; assign(const charT* ptr, flag_type f = regex_constants::normal);</PRE>
<B>
<P>
Effects:</B> Returns <CODE>assign(string_type(ptr), f)</CODE>.</P><PRE>basic_regex&amp; assign(const charT* first, const charT* last,
flag_type f = regex_constants::normal);</PRE>
<B>
<P>
Effects:</B> Returns <CODE>assign(string_type(first, last), f)</CODE>.</P><PRE>template &lt;class string_traits, class A&gt;
basic_regex&amp; assign(const basic_string&lt;charT, string_traits, A&gt;&amp; s,
flag_type f = regex_constants::normal);</PRE>
<B>
<P>
Throws: </B><CODE>bad_expression</CODE> if <I>s</I> is not a valid regular
expression.</P><B>
<P>
Returns:</B> <CODE>*this</CODE>.</P><B>
<P>
Effects:</B> Assigns the regular expression contained in the string <I>s</I>,
interpreted according the <A href="syntax_option_type.html">option flags</A> specified
in <I>f</I>. The postconditions of this function are indicated in the
table:</P><I>
<P>
<DIV align="center">
<P></P>
</I>
<P align="center">
<CENTER>
<TABLE id="Table9" cellSpacing="1" cellPadding="7" width="624" border="1">
<TBODY>
<TR>
<TD vAlign="top" width="50%"><B>
<P>
Element</B>
</P>
</TD>
<TD vAlign="top" width="50%"><B>
<P>
Value</B> </P></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>empty()</P>
</TD>
<TD vAlign="top" width="50%">
<P>false</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>size()</P>
</TD>
<TD vAlign="top" width="50%">
<P>s.size()</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>str()</P>
</TD>
<TD vAlign="top" width="50%">
<P>s</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>getflags()</P>
</TD>
<TD vAlign="top" width="50%">
<P>f</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>mark_count()</P>
</TD>
<TD vAlign="top" width="50%">
<P>The number of marked sub-expressions within the expression.</P>
<P></P>
</TD>
</TR>
</TBODY></TD></TR></TABLE></CENTER>
<P></P>
</DIV><PRE>template &lt;class InputIterator&gt;
basic_regex&amp; assign(InputIterator first, InputIterator last,
flag_type f = regex_constants::normal);</PRE>
<B>
<P>
Requires:</B> The type InputIterator corresponds to the Input Iterator
requirements (24.1.1).</P><B>
<P>
Effects:</B> Returns <CODE>assign(string_type(first, last), f)</CODE>.</P>
<H4>basic_regex constant operations</H4>
<PRE>Allocator get_allocator() const;</PRE>
<B>
<P>
Effects:</B> Returns a copy of the Allocator that was passed to the object's
constructor.</P><PRE>flag_type getflags() const;</PRE>
<B>
<P>
Effects:</B> Returns a copy of the regular expression syntax flags that were
passed to the object's constructor, or the last call to <CODE>assign.</P></CODE><PRE>basic_string&lt;charT&gt; str() const;</PRE>
<B>
<P>
Effects:</B> Returns a copy of the character sequence passed to the object's
constructor, or the last call to <CODE>assign.</P></CODE><PRE>int compare(basic_regex&amp; e)const;</PRE>
<B>
<P>
Effects:</B> If <CODE>getflags() == e.getflags()</CODE> then returns <CODE>str().compare(e.str())</CODE>,
otherwise returns <CODE>getflags() - e.getflags()</CODE>.</P>
<H4>basic_regex locale</H4>
<PRE>locale_type imbue(locale_type l);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>traits_inst.imbue(l)</CODE> where <CODE>
traits_inst </CODE>is a (default initialized) instance of the template
parameter <CODE>traits</CODE> stored within the object. Calls to imbue
invalidate any currently contained regular expression.</P><B>
<P>
Postcondition:</B> <CODE>empty() == true</CODE>.</P><PRE>locale_type getloc() const;</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>traits_inst.getloc()</CODE> where <CODE>
traits_inst </CODE>is a (default initialized) instance of the template
parameter <CODE>traits</CODE> stored within the object.</P>
<H4>basic_regex swap</H4>
<PRE>void swap(basic_regex&amp; e) throw();</PRE>
<B>
<P>
Effects:</B> Swaps the contents of the two regular expressions. </P><B>
<P>
Postcondition:</B> <CODE>*this</CODE> contains the characters that were in <I>e</I>,
<I>e </I>contains the regular expression that was in <CODE>*this</CODE>. </P><B>
<P>
Complexity:</B> constant time. </P>
<H4>basic_regex non-member functions</H4>
<H5>basic_regex non-member comparison operators&nbsp;</H5>
<PRE>template &lt;class charT, class traits, class Allocator&gt;
bool operator == (const basic_regex&lt;charT, traits, Allocator&gt;&amp; lhs,
const basic_regex&lt;charT, traits, Allocator&gt;&amp; rhs);</PRE>
<B>
<P>
Effects:</B> Returns <CODE>lhs.compare(rhs) == 0</CODE>.</P><PRE>template &lt;class charT, class traits, class Allocator&gt;
bool operator != (const basic_regex&lt;charT, traits, Allocator&gt;&amp; lhs,
const basic_regex&lt;charT, traits, Allocator&gt;&amp; rhs);</PRE>
<B>
<P>
Effects:</B> Returns <CODE>lhs.compare(rhs) != 0</CODE>.</P><PRE>template &lt;class charT, class traits, class Allocator&gt;
bool operator &lt; (const basic_regex&lt;charT, traits, Allocator&gt;&amp; lhs,
const basic_regex&lt;charT, traits, Allocator&gt;&amp; rhs);</PRE>
<B>
<P>
Effects:</B> Returns <CODE>lhs.compare(rhs) &lt; 0</CODE>.</P><PRE>template &lt;class charT, class traits, class Allocator&gt;
bool operator &lt;= (const basic_regex&lt;charT, traits, Allocator&gt;&amp; lhs,
const basic_regex&lt;charT, traits, Allocator&gt;&amp; rhs);</PRE>
<B>
<P>
Effects:</B> Returns <CODE>lhs.compare(rhs) &lt;= 0</CODE>.</P><PRE>template &lt;class charT, class traits, class Allocator&gt;
bool operator &gt;= (const basic_regex&lt;charT, traits, Allocator&gt;&amp; lhs,
const basic_regex&lt;charT, traits, Allocator&gt;&amp; rhs);</PRE>
<B>
<P>
Effects:</B> Returns <CODE>lhs.compare(rhs) &gt;= 0</CODE>.</P><PRE>template &lt;class charT, class traits, class Allocator&gt;
bool operator &gt; (const basic_regex&lt;charT, traits, Allocator&gt;&amp; lhs,
const basic_regex&lt;charT, traits, Allocator&gt;&amp; rhs);</PRE>
<B>
<P>
Effects:</B> Returns <CODE>lhs.compare(rhs) &gt; 0</CODE>.</P>
<H5>basic_regex inserter.</H5>
<PRE>template &lt;class charT, class io_traits, class re_traits, class Allocator&gt;
basic_ostream&lt;charT, io_traits&gt;&amp;
operator &lt;&lt; (basic_ostream&lt;charT, io_traits&gt;&amp; os
const basic_regex&lt;charT, re_traits, Allocator&gt;&amp; e);</PRE>
<B>
<P>
Effects:</B> Returns (os &lt;&lt; e.str()).</P>
<H5>basic_regex non-member swap</H5>
<PRE>template &lt;class charT, class traits, class Allocator&gt;
void swap(basic_regex&lt;charT, traits, Allocator&gt;&amp; lhs,
basic_regex&lt;charT, traits, Allocator&gt;&amp; rhs);</PRE>
<B>
<P>
Effects:</B> calls <CODE>lhs.swap(rhs)</CODE>.</P>
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

86
doc/Attic/contacts.html Normal file
View File

@ -0,0 +1,86 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Contacts</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">Contacts and Acknowledgements</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<P>The author can be contacted at <A href="mailto:John_Maddock@compuserve.com">John_Maddock@compuserve.com</A>,
the home page for this library is at <A href="http://ourworld.compuserve.com/homepages/John_Maddock/regexpp.htm">
http://ourworld.compuserve.com/homepages/John_Maddock/regexpp.htm</A>, and
the official boost version can be obtained from <A href="../libraries.htm">www.boost.org/libraries.htm</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<72> 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>Useful further information can be found at:
</P>
<P>A short tutorial on regular expressions <A href="http://www.devshed.com/Server_Side/Administration/RegExp/">
can be found here</A>.</P>
<P>The <A href="http://www.opengroup.org/onlinepubs/7908799/toc.htm">Open Unix
Specification</A> contains a wealth of useful material, including the
regular expression syntax, and specifications for <A href="http://www.opengroup.org/onlinepubs/7908799/xsh/regex.h.html">
&lt;regex.h&gt;</A> and <A href="http://www.opengroup.org/onlinepubs/7908799/xsh/nl_types.h.html">
&lt;nl_types.h&gt;</A>.
</P>
<P>The <A href="http://www.cs.ucr.edu/~stelo/pattern.html">Pattern Matching Pointers</A>
site is a "must visit" resource for anyone interested in pattern matching.
</P>
<P><A href="http://glimpse.cs.arizona.edu/">Glimpse and Agrep</A>, use a
simplified regular expression syntax to achieve faster search times.
</P>
<P><A href="http://glimpse.cs.arizona.edu/udi.html">Udi Manber</A> and <A href="http://www.dcc.uchile.cl/~rbaeza/">
Ricardo Baeza-Yates</A>
both have a selection of useful pattern matching papers available from their
respective web sites.
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

107
doc/Attic/examples.html Normal file
View File

@ -0,0 +1,107 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Examples</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">Examples</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<P>There are three demo applications that ship with this library, they all come
with makefiles for Borland, Microsoft and gcc compilers, otherwise you will
have to create your own makefiles.
</P>
<H5>regress.exe:
</H5>
<P>A regression test application that gives the matching/searching algorithms a
full workout. The presence of this program is your guarantee that the library
will behave as claimed - at least as far as those items tested are concerned -
if anyone spots anything that isn't being tested I'd be glad to hear about it.
</P>
<P>Files: <A href="../test/regress/parse.cpp">parse.cpp</A>, <A href="../test/regress/regress.cpp">
regress.cpp</A>, <A href="../test/regress/tests.cpp">tests.cpp</A>.
</P>
<H5>jgrep.exe
</H5>
<P>A simple grep implementation, run with no command line options to find out its
usage. Look at <A href="../src/fileiter.cpp">fileiter.cpp</A>/fileiter.hpp and
the mapfile class to see an example of a "smart" bidirectional iterator that
can be used with boost.regex or any other STL algorithm.
</P>
<P>Files: <A href="../example/jgrep/jgrep.cpp">jgrep.cpp</A>, <A href="../example/jgrep/main.cpp">
main.cpp</A>.
</P>
<H5>timer.exe
</H5>
<P>A simple interactive expression matching application, the results of all
matches are timed, allowing the programmer to optimize their regular
expressions where performance is critical.
</P>
<P>Files: <A href="../example/timer/regex_timer.cpp">regex_timer.cpp</A>.
</P>
<H5>Code snippets</H5>
<P>The snippets examples contain the code examples used in the documentation:</P>
<P><A href="../example/snippets/credit_card_example.cpp">credit_card_example.cpp</A>:
Credit card number formatting code.</P>
<P><A href="../example/snippets/partial_regex_grep.cpp">partial_regex_grep.cpp</A>:
Search example using partial matches.</P>
<P><A href="../example/snippets/partial_regex_match.cpp">partial_regex_match.cpp</A>:
regex_match example using partial matches.</P>
<P><A href="../example/snippets/regex_grep_example_1.cpp">regex_grep_example_1.cpp</A>:
regex_grep example 1: searches a cpp file for class definitions.</P>
<P><A href="../example/snippets/regex_grep_example_2.cpp">regex_grep_example_2.cpp</A>:
regex_grep example 2: searches a cpp file for class definitions, using a global
callback function.
</P>
<P><A href="../example/snippets/regex_grep_example_3.cpp">regex_grep_example_3.cpp</A>:
regex_grep example 2: searches a cpp file for class definitions, using a bound
member function callback.</P>
<P><A href="../example/snippets/regex_grep_example_4.cpp">regex_grep_example_4.cpp</A>:
regex_grep example 2: searches a cpp file for class definitions, using a C++
Builder closure as a callback.</P>
<P><A href="../example/snippets/regex_match_example.cpp">regex_match_example.cpp</A>:
ftp based regex_match example.</P>
<P><A href="../example/snippets/regex_merge_example.cpp">regex_merge_example.cpp</A>:
regex_merge example: converts a C++ file to syntax highlighted HTML.</P>
<P><A href="../example/snippets/regex_replace_example.cpp">regex_replace_example.cpp</A>:
regex_replace example: converts a C++ file to syntax highlighted HTML</P>
<P><A href="../example/snippets/regex_search_example.cpp">regex_search_example.cpp</A>:
regex_search example: searches a cpp file for class definitions.</P>
<P><A href="../example/snippets/regex_split_example_1.cpp">regex_split_example_1.cpp</A>:
regex_split example: split a string into tokens.</P>
<P><A href="../example/snippets/regex_split_example_2.cpp">regex_split_example_2.cpp</A>
: regex_split example: spit out linked URL's.
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

118
doc/Attic/faq.html Normal file
View File

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

View File

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

51
doc/Attic/headers.html Normal file
View File

@ -0,0 +1,51 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Headers</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">Headers</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<P>There are two main headers used by this library: &lt;boost/regex.hpp&gt;
provides full access to the entire library, while &lt;boost/cregex.hpp&gt;
provides access to just the high level class RegEx, and the POSIX API
functions.
</P>
<P>There is also a header containing only forward declarations
&lt;boost/regex_fwd.hpp&gt; for use when an interface is dependent upon
boost::basic_regex, but otherwise does not need the full definitions.</P>
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

44
doc/Attic/history.html Normal file
View File

@ -0,0 +1,44 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: History</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">History</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<P>Todo.</P>
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -0,0 +1,44 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Implementation</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">Implementation</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<P>Todo.</P>
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

236
doc/Attic/install.html Normal file
View File

@ -0,0 +1,236 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Index</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">Installation</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<P><EM>[ </EM><STRONG><I>Important</I></STRONG><EM>: If you are upgrading from the
2.x version of this library then you will find a number of changes to the
documented header names and library interfaces, existing code should still
compile unchanged however - see </EM><A href="appendix.htm#upgrade"><FONT color="#0000ff">
<EM>Note for Upgraders</EM></FONT></A><EM>. ]</EM></P>
<P>When you extract the library from its zip file, you must preserve its internal
directory structure (for example by using the -d option when extracting). If
you didn't do that when extracting, then you'd better stop reading this, delete
the files you just extracted, and try again!
</P>
<P>This library should not need configuring before use; most popular
compilers/standard libraries/platforms are already supported "as is". If you do
experience configuration problems, or just want to test the configuration with
your compiler, then the process is the same as for all of boost; see the <A href="../config/config.htm">
configuration library documentation</A>.</P>
<P>The library will encase all code inside namespace boost.
</P>
<P>Unlike some other template libraries, this library consists of a mixture of
template code (in the headers) and static code and data (in cpp files).
Consequently it is necessary to build the library's support code into a library
or archive file before you can use it, instructions for specific platforms are
as follows:
</P>
<P><B><A name="bcb"></A>Borland C++ Builder:</B>
</P>
<UL>
<LI>
Open up a console window and change to the &lt;boost&gt;\libs\regex\build
directory.
<LI>
Select the appropriate makefile (bcb4.mak for C++ Builder 4, bcb5.mak for C++
Builder 5, and bcb6.mak for C++ Builder 6).
<LI>
Invoke the makefile (pass the full path to your version of make if you have
more than one version installed, the makefile relies on the path to make to
obtain your C++ Builder installation directory and tools) for example:
</LI>
</UL>
<PRE>make -fbcb5.mak</PRE>
<P>The build process will build a variety of .lib and .dll files (the exact number
depends upon the version of Borland's tools you are using) the .lib and dll
files will be in a sub-directory called bcb4 or bcb5 depending upon the
makefile used. To install the libraries into your development system use:</P>
<P>make -fbcb5.mak install</P>
<P>library files will be copied to &lt;BCROOT&gt;/lib and the dll's to
&lt;BCROOT&gt;/bin, where &lt;BCROOT&gt; corresponds to the install path of
your Borland C++ tools.
</P>
<P>You may also remove temporary files created during the build process (excluding
lib and dll files) by using:</P>
<P>make -fbcb5.mak clean</P>
<P>Finally when you use regex++ it is only necessary for you to add the
&lt;boost&gt; root director to your list of include directories for that
project. It is not necessary for you to manually add a .lib file to the
project; the headers will automatically select the correct .lib file for your
build mode and tell the linker to include it. There is one caveat however: the
library can not tell the difference between VCL and non-VCL enabled builds when
building a GUI application from the command line, if you build from the command
line with the 5.5 command line tools then you must define the pre-processor
symbol _NO_VCL in order to ensure that the correct link libraries are selected:
the C++ Builder IDE normally sets this automatically. Hint, users of the 5.5
command line tools may want to add a -D_NO_VCL to bcc32.cfg in order to set
this option permanently.
</P>
<P>If you would prefer to do a static link to the regex libraries even when using
the dll runtime then define BOOST_REGEX_STATIC_LINK, and if you want to
suppress automatic linking altogether (and supply your own custom build of the
lib) then define BOOST_REGEX_NO_LIB.</P>
<P>If you are building with C++ Builder 6, you will find that
&lt;boost/regex.hpp&gt; can not be used in a pre-compiled header (the actual
problem is in &lt;locale&gt; which gets included by &lt;boost/regex.hpp&gt;),
if this causes problems for you, then try defining BOOST_NO_STD_LOCALE when
building, this will disable some features throughout boost, but may save you a
lot in compile times!</P>
<P><B><A name="vc"></A>Microsoft Visual C++ 6</B><STRONG> and 7</STRONG></P>
<P>You need version 6 of MSVC to build this library. If you are using VC5 then you
may want to look at one of the previous releases of this <A href="http://ourworld.compuserve.com/homepages/john_maddock/regexpp.htm">
library</A>
</P>
<P>Open up a command prompt, which has the necessary MSVC environment variables
defined (for example by using the batch file Vcvars32.bat installed by the
Visual Studio installation), and change to the &lt;boost&gt;\libs\regex\build
directory.
</P>
<P>Select the correct makefile - vc6.mak for "vanilla" Visual C++ 6 or
vc6-stlport.mak if you are using STLPort.</P>
<P>Invoke the makefile like this:</P>
<P>nmake -fvc6.mak</P>
<P>You will now have a collection of lib and dll files in a "vc6" subdirectory, to
install these into your development system use:</P>
<P>nmake -fvc6.mak install</P>
<P>The lib files will be copied to your &lt;VC6&gt;\lib directory and the dll
files to &lt;VC6&gt;\bin, where &lt;VC6&gt; is the root of your Visual C++ 6
installation.</P>
<P>You can delete all the temporary files created during the build (excluding lib
and dll files) using:</P>
<P>nmake -fvc6.mak clean
</P>
<P>Finally when you use regex++ it is only necessary for you to add the
&lt;boost&gt; root directory to your list of include directories for that
project. It is not necessary for you to manually add a .lib file to the
project; the headers will automatically select the correct .lib file for your
build mode and tell the linker to include it.
</P>
<P>Note that if you want to statically link to the regex library when using the
dynamic C++ runtime, define BOOST_REGEX_STATIC_LINK when building your project
(this only has an effect for release builds). If you want to add the source
directly to your project then define BOOST_REGEX_NO_LIB to disable automatic
library selection.</P>
<P><STRONG><I>Important</I></STRONG><EM>: there have been some reports of
compiler-optimisation bugs affecting this library, (particularly with VC6
versions prior to service patch 5) the workaround is to build the library using
/Oityb1 rather than /O2. That is to use all optimisation settings except /Oa.
This problem is reported to affect some standard library code as well (in fact
I'm not sure if the problem is with the regex code or the underlying standard
library), so it's probably worthwhile applying this workaround in normal
practice in any case.</EM></P>
<P>Note: if you have replaced the C++ standard library that comes with VC6, then
when you build the library you must ensure that the environment variables
"INCLUDE" and "LIB" have been updated to reflect the include and library paths
for the new library - see vcvars32.bat (part of your Visual Studio
installation) for more details. Alternatively if STLPort is in c:/stlport then
you could use:</P>
<P>nmake INCLUDES="-Ic:/stlport/stlport" XLFLAGS="/LIBPATH:c:/stlport/lib"
-fvc6-stlport.mak</P>
<P>If you are building with the full STLPort v4.x, then use the vc6-stlport.mak
file provided and set the environment variable STLPORT_PATH to point to the
location of your STLport installation (Note that the full STLPort libraries
appear not to support single-thread static builds).
<BR>
&nbsp;
<BR>
&nbsp;
</P>
<P><B><A name="gcc"></A>GCC(2.95 and 3.x)</B>
</P>
<P>There is a conservative makefile for the g++ compiler. From the command prompt
change to the &lt;boost&gt;/libs/regex/build directory and type:
</P>
<P>make -fgcc.mak
</P>
<P>At the end of the build process you should have a gcc sub-directory containing
release and debug versions of the library (libboost_regex.a and
libboost_regex_debug.a). When you build projects that use regex++, you will
need to add the boost install directory to your list of include paths and add
&lt;boost&gt;/libs/regex/build/gcc/libboost_regex.a to your list of library
files.
</P>
<P>There is also a makefile to build the library as a shared library:</P>
<P>make -fgcc-shared.mak</P>
<P>which will build libboost_regex.so and libboost_regex_debug.so.</P>
<P>Both of the these makefiles support the following environment variables:</P>
<P>CXXFLAGS: extra compiler options - note that this applies to both the debug and
release builds.</P>
<P>INCLUDES: additional include directories.</P>
<P>LDFLAGS: additional linker options.</P>
<P>LIBS: additional library files.</P>
<P>For the more adventurous there is a configure script in
&lt;boost&gt;/libs/config; see the <A href="../config/config.htm">config library
documentation</A>.</P>
<P><B><A name="sun"></A>Sun Workshop 6.1</B></P>
<P>There is a makefile for the sun (6.1) compiler (C++ version 3.12). From the
command prompt change to the &lt;boost&gt;/libs/regex/build directory and type:
</P>
<P>dmake -f sunpro.mak
</P>
<P>At the end of the build process you should have a sunpro sub-directory
containing single and multithread versions of the library (libboost_regex.a,
libboost_regex.so, libboost_regex_mt.a and libboost_regex_mt.so). When you
build projects that use regex++, you will need to add the boost install
directory to your list of include paths and add
&lt;boost&gt;/libs/regex/build/sunpro/ to your library search path.
</P>
<P>Both of the these makefiles support the following environment variables:</P>
<P>CXXFLAGS: extra compiler options - note that this applies to both the single
and multithreaded builds.</P>
<P>INCLUDES: additional include directories.</P>
<P>LDFLAGS: additional linker options.</P>
<P>LIBS: additional library files.</P>
<P>LIBSUFFIX: a suffix to mangle the library name with (defaults to nothing).</P>
<P>This makefile does not set any architecture specific options like -xarch=v9,
you can set these by defining the appropriate macros, for example:</P>
<P>dmake CXXFLAGS="-xarch=v9" LDFLAGS="-xarch=v9" LIBSUFFIX="_v9" -f sunpro.mak</P>
<P>will build v9 variants of the regex library named libboost_regex_v9.a etc.</P>
<P><B><A name="other"></A>Other compilers:</B>
</P>
<P>There is a generic makefile (<A href="build/generic.mak">generic.mak</A>)
provided in &lt;boost-root&gt;/libs/regex/build - see that makefile for details
of environment variables that need to be set before use. Alternatively you can
using the <A href="../../tools/build/index.html">Jam based build system</A>. If
you need to configure the library for your platform, then refer to the <A href="../config/config.htm">
config library documentation</A>
.
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

174
doc/Attic/introduction.html Normal file
View File

@ -0,0 +1,174 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Introduction</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">Introduction</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<P>Regular expressions are a form of pattern-matching that are often used in text
processing; many users will be familiar with the Unix utilities <I>grep</I>, <I>sed</I>
and <I>awk</I>, and the programming language <I>perl</I>, each of which make
extensive use of regular expressions. Traditionally C++ users have been limited
to the POSIX C API's for manipulating regular expressions, and while regex++
does provide these API's, they do not represent the best way to use the
library. For example regex++ can cope with wide character strings, or search
and replace operations (in a manner analogous to either sed or perl), something
that traditional C libraries can not do.</P>
<P>The class <A href="basic_regex.html">boost::basic_regex</A> is the key class in
this library; it represents a "machine readable" regular expression, and is
very closely modelled on std::basic_string, think of it as a string plus the
actual state-machine required by the regular expression algorithms. Like
std::basic_string there are two typedefs that are almost always the means by
which this class is referenced:</P>
<pre><B>namespace </B>boost{
<B>template</B> &lt;<B>class</B> charT,
<B> class</B> traits = regex_traits&lt;charT&gt;,
<B>class</B> Allocator = std::allocator&lt;charT&gt; &gt;
<B>class</B> basic_regex;
<B>typedef</B> basic_regex&lt;<B>char</B>&gt; regex;
<B>typedef</B> basic_regex&lt;<B>wchar_t&gt;</B> wregex;
}</pre>
<P>To see how this library can be used, imagine that we are writing a credit card
processing application. Credit card numbers generally come as a string of
16-digits, separated into groups of 4-digits, and separated by either a space
or a hyphen. Before storing a credit card number in a database (not necessarily
something your customers will appreciate!), we may want to verify that the
number is in the correct format. To match any digit we could use the regular
expression [0-9], however ranges of characters like this are actually locale
dependent. Instead we should use the POSIX standard form [[:digit:]], or the
regex++ and perl shorthand for this \d (note that many older libraries tended
to be hard-coded to the C-locale, consequently this was not an issue for them).
That leaves us with the following regular expression to validate credit card
number formats:</P>
<P>(\d{4}[- ]){3}\d{4}</P>
<P>Here the parenthesis act to group (and mark for future reference)
sub-expressions, and the {4} means "repeat exactly 4 times". This is an example
of the extended regular expression syntax used by perl, awk and egrep. Regex++
also supports the older "basic" syntax used by sed and grep, but this is
generally less useful, unless you already have some basic regular expressions
that you need to reuse.</P>
<P>Now lets take that expression and place it in some C++ code to validate the
format of a credit card number:</P>
<PRE><B>bool</B> validate_card_format(<B>const</B> std::string s)
{
<B>static</B> <B>const</B> <A href="basic_regex.html">boost::regex</A> e("(\\d{4}[- ]){3}\\d{4}");
<B>return</B> <A href="regex_match.html">regex_match</A>(s, e);
}</PRE>
<P>Note how we had to add some extra escapes to the expression: remember that the
escape is seen once by the C++ compiler, before it gets to be seen by the
regular expression engine, consequently escapes in regular expressions have to
be doubled up when embedding them in C/C++ code. Also note that all the
examples assume that your compiler supports Koenig lookup, if yours doesn't
(for example VC6), then you will have to add some boost:: prefixes to some of
the function calls in the examples.</P>
<P>Those of you who are familiar with credit card processing, will have realised
that while the format used above is suitable for human readable card numbers,
it does not represent the format required by online credit card systems; these
require the number as a string of 16 (or possibly 15) digits, without any
intervening spaces. What we need is a means to convert easily between the two
formats, and this is where search and replace comes in. Those who are familiar
with the utilities <I>sed</I> and <I>perl</I> will already be ahead here; we
need two strings - one a regular expression - the other a "<A href="format_syntax.html">format
string</A>" that provides a description of the text to replace the match
with. In regex++ this search and replace operation is performed with the
algorithm regex_replace, for our credit card example we can write two algorithms
like this to provide the format conversions:</P>
<PRE><I>// match any format with the regular expression:
</I><B>const</B> boost::regex e("\\A(\\d{3,4})[- ]?(\\d{4})[- ]?(\\d{4})[- ]?(\\d{4})\\z");
<B>const</B> std::string machine_format("\\1\\2\\3\\4");
<B>const</B> std::string human_format("\\1-\\2-\\3-\\4");
std::string machine_readable_card_number(<B>const</B> std::string s)
{
<B>return</B> <A href="regex_replace.html">regex_replace</A>(s, e, machine_format, boost::match_default | boost::format_sed);
}
std::string human_readable_card_number(<B>const</B> std::string s)
{
<B>return</B> <A href="regex_replace.html">regex_replace</A>(s, e, human_format, boost::match_default | boost::format_sed);
}</PRE>
<P>Here we've used marked sub-expressions in the regular expression to split out
the four parts of the card number as separate fields, the format string then
uses the sed-like syntax to replace the matched text with the reformatted
version.</P>
<P>In the examples above, we haven't directly manipulated the results of a regular
expression match, however in general the result of a match contains a number of
sub-expression matches in addition to the overall match. When the library needs
to report a regular expression match it does so using an instance of the class <A href="match_results.html">
match_results</A>, as before there are typedefs of this class for the most
common cases:
</P>
<PRE><B>namespace </B>boost{
<B>typedef</B> match_results&lt;<B>const</B> <B>char</B>*&gt; cmatch;
<B>typedef</B> match_results&lt;<B>const</B> <B>wchar_t</B>*&gt; wcmatch;
<STRONG>typedef</STRONG> match_results&lt;std::string::const_iterator&gt; smatch;
<STRONG>typedef</STRONG> match_results&lt;std::wstring::const_iterator&gt; wsmatch;
}</PRE>
<P>The algorithms <A href="regex_search.html">regex_search</A> and <A href="regex_grep.html">
regex_grep</A> (i.e. finding all matches in a string) make use of
match_results to report what matched.</P>
<P>Note that these algorithms are not restricted to searching regular C-strings,
any bidirectional iterator type can be searched, allowing for the possibility
of seamlessly searching almost any kind of data.
</P>
<P>For search and replace operations in addition to the algorithm <A href="regex_replace.html">
regex_replace</A> that we have already seen, the algorithm <A href="regex_format.html">
regex_format</A> takes the result of a match and a format string, and
produces a new string by merging the two.</P>
<P>For those that dislike templates, there is a high level wrapper class RegEx
that is an encapsulation of the lower level template code - it provides a
simplified interface for those that don't need the full power of the library,
and supports only narrow characters, and the "extended" regular expression
syntax.
</P>
<P>The <A href="posix_api.html">POSIX API</A> functions: regcomp, regexec, regfree
and regerror, are available in both narrow character and Unicode versions, and
are provided for those who need compatibility with these API's.
</P>
<P>Finally, note that the library now has run-time <A href="localisation.html">localization</A>
support, and recognizes the full POSIX regular expression syntax - including
advanced features like multi-character collating elements and equivalence
classes - as well as providing compatibility with other regular expression
libraries including GNU and BSD4 regex packages, and to a more limited extent
perl 5.
</P>
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

1126
doc/Attic/localisation.html Normal file

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -0,0 +1,390 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: class match_results</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">class match_results</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<H3>Contents</H3>
<DL class="index">
<DT><A href="#synopsis">Synopsis</A> <DT><A href="#description">Description</A></DT>
</DL>
<H3><A name="synopsis"></A>Synopsis</H3>
<P>#include &lt;<A href="../../boost/regex.hpp">boost/regex.hpp</A>&gt;
</P>
<P>Regular expressions are different from many simple pattern-matching algorithms
in that as well as finding an overall match they can also produce
sub-expression matches: each sub-expression being delimited in the pattern by a
pair of parenthesis (...). There has to be some method for reporting
sub-expression matches back to the user: this is achieved this by defining a
class <I>match_results</I> that acts as an indexed collection of sub-expression
matches, each sub-expression match being contained in an object of type <I><A href="sub_match.html">
sub_match</A></I>
.
<P>Template class match_results denotes a collection of character sequences
representing the result of a regular expression match. Objects of type
match_results are passed to the algorithms <A href="regex_match.html">regex_match</A>
and <A href="regex_search">regex_search</A>, and are returned by the iterator <A href="regex_iterator.html">
regex_iterator</A>
.&nbsp; Storage for the collection is allocated and freed as necessary by the
member functions of class match_results.
<P>The template class match_results conforms to the requirements of a Sequence, as
specified in (lib.sequence.reqmts), except that only operations defined for
const-qualified Sequences are supported.</P>
<P>Class template match_results is most commonly used as one of the typedefs
cmatch, wcmatch, smatch, or wsmatch:</P>
<PRE>template &lt;class BidirectionalIterator,
class Allocator = allocator&lt;sub_match&lt;BidirectionalIterator&gt; &gt;
class match_results;
typedef match_results&lt;const char*&gt; cmatch;
typedef match_results&lt;const wchar_t*&gt; wcmatch;
typedef match_results&lt;string::const_iterator&gt; smatch;
typedef match_results&lt;wstring::const_iterator&gt; wsmatch;
template &lt;class BidirectionalIterator,
class Allocator = allocator&lt;sub_match&lt;BidirectionalIterator&gt; &gt;
class match_results
{
public:
typedef sub_match&lt;BidirectionalIterator&gt; value_type;
typedef const value_type&amp; const_reference;
typedef const_reference reference;
typedef implementation defined const_iterator;
typedef const_iterator iterator;
typedef typename iterator_traits&lt;BidirectionalIterator&gt;::difference_type difference_type;
typedef typename Allocator::size_type size_type;
typedef Allocator allocator_type;
typedef typename iterator_traits&lt;BidirectionalIterator&gt;::value_type char_type;
typedef basic_string&lt;char_type&gt; string_type;
// construct/copy/destroy:
explicit match_results(const Allocator&amp; a = Allocator());
match_results(const match_results&amp; m);
match_results&amp; operator=(const match_results&amp; m);
~match_results();
// size:
size_type size() const;
size_type max_size() const;
bool empty() const;
// element access:
difference_type length(int sub = 0) const;
difference_type position(unsigned int sub = 0) const;
string_type str(int sub = 0) const;
const_reference operator[](int n) const;
const_reference prefix() const;
const_reference suffix() const;
const_iterator begin() const;
const_iterator end() const;
// format:
template &lt;class OutputIterator&gt;
OutputIterator format(OutputIterator out,
const string_type&amp; fmt,
match_flag_type flags = format_default) const;
string_type format(const string_type&amp; fmt,
match_flag_type flags = format_default) const;
allocator_type get_allocator() const;
void swap(match_results&amp; that);
};
template &lt;class BidirectionalIterator, class Allocator&gt;
bool operator == (const match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m1,
const match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m2);
template &lt;class BidirectionalIterator, class Allocator&gt;
bool operator != (const match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m1,
const match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m2);
template &lt;class charT, class traits, class BidirectionalIterator, class Allocator&gt;
basic_ostream&lt;charT, traits&gt;&amp;
operator &lt;&lt; (basic_ostream&lt;charT, traits&gt;&amp; os,
const match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m);
template &lt;class BidirectionalIterator, class Allocator&gt;
void swap(match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m1,
match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m2);</PRE>
<H3><A name="description"></A>Description</H3>
<H4>match_results constructors</H4>
<P>In all <CODE>match_results</CODE> constructors, a copy of the Allocator
argument is used for any memory allocation performed by the constructor or
member functions during the lifetime of the object.
</P>
<PRE>match_results(const Allocator&amp; a = Allocator());</PRE>
<B>
<P>
Effects:</B> Constructs an object of class match_results. The postconditions
of this function are indicated in Table RE16:</P><I>
<H6 align="center">
Table RE16--</I>match_results(const Allocator&amp;)<I> effects</H6>
<P>
<DIV align="center">
<P></P>
</I>
<P align="center">
<CENTER>
<TABLE id="Table2" cellSpacing="1" cellPadding="7" width="624" border="1">
<TBODY>
<TR>
<TD vAlign="top" width="50%"><B>
<P>
Element</B>
</P>
</TD>
<TD vAlign="top" width="50%"><B>
<P>
Value</B> </P></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>empty()</P>
</TD>
<TD vAlign="top" width="50%">
<P>true</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>size()</P>
</TD>
<TD vAlign="top" width="50%">
<P>0</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>str()</P>
</TD>
<TD vAlign="top" width="50%">
<P>basic_string&lt;charT&gt;()</P>
<P></P>
</TD>
</TR>
</TBODY></TD></TR></TABLE></CENTER>
<P></P>
</DIV><PRE>match_results(const match_results&amp; m);</PRE>
<B>
<P>
Effects:</B> Constructs an object of class match_results, as a copy of
m.</P><PRE>match_results&amp; operator=(const match_results&amp; m);</PRE>
<B>
<P>
Effects:</B> Assigns m to *this. The postconditions of this function are
indicated in Table RE17:</P>
<H6 align="center">Table RE17--match_results(const Allocator&amp;) effects</H6>
<P>
<DIV align="center">
<P></P>
<P align="center">
<CENTER>
<TABLE id="Table3" cellSpacing="1" cellPadding="7" width="624" border="1">
<TBODY>
<TR>
<TD vAlign="top" width="50%"><B>
<P>
Element</B>
</P>
</TD>
<TD vAlign="top" width="50%"><B>
<P>
Value</B>
</P>
</TD></TR>
<TR>
<TD vAlign="top" width="50%">
<P>empty()</P>
</TD>
<TD vAlign="top" width="50%">
<P>m.empty().</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>size()</P>
</TD>
<TD vAlign="top" width="50%">
<P>m.size().</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>str(n)</P>
</TD>
<TD vAlign="top" width="50%">
<P>m.str(n) for all integers n &lt; m.size().</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>prefix()</P>
</TD>
<TD vAlign="top" width="50%">
<P>m.prefix().</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>suffix()</P>
</TD>
<TD vAlign="top" width="50%">
<P>m.suffix().</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>(*this)[n]</P>
</TD>
<TD vAlign="top" width="50%">
<P>m[n] for all integers n &lt; m.size().</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>length(n)</P>
</TD>
<TD vAlign="top" width="50%">
<P>m.length(n) for all integers n &lt; m.size().</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>position(n)</P>
</TD>
<TD vAlign="top" width="50%">
<P>m.position(n) for all integers n &lt; m.size().</P>
<P></P>
</TD>
</TR>
</TBODY></TD></TR></TABLE></CENTER>
<P></P>
</DIV>
<H4>match_results size</H4>
<PRE>size_type size()const;</PRE>
<B>
<P>
Effects:</B> Returns the number of sub_match elements stored in *this.</P><PRE>size_type max_size()const;</PRE>
<B>
<P>
Effects:</B> Returns the maximum number of sub_match elements that can be
stored in *this.</P><PRE>bool empty()const;</PRE>
<B>
<P>
Effects:</B> Returns <CODE>size() == 0</CODE>.</P>
<H4>match_results element access</H4>
<PRE>difference_type length(int sub = 0)const;</PRE>
<B>
<P>
Effects:</B> Returns <CODE>(*this)[sub].length()</CODE>.</P><PRE>difference_type position(unsigned int sub = 0)const;</PRE>
<B>
<P>
Effects:</B> Returns <CODE>std::distance(prefix().first,
(*this)[sub].first).</P></CODE><PRE>string_type str(int sub = 0)const;</PRE>
<B>
<P>
Effects:</B> Returns <CODE>string_type((*this)[sub]).</P></CODE><PRE>const_reference operator[](int n) const;</PRE>
<B>
<P>
Effects:</B> Returns a reference to the <CODE>sub_match </CODE>object
representing the character sequence that matched marked sub-expression <I>n</I>.
If <CODE>n == 0 </CODE>then returns a reference to a <CODE>sub_match</CODE> object
representing the character sequence that matched the whole regular
expression.</P><PRE>const_reference prefix()const;</PRE>
<B>
<P>
Effects:</B> Returns a reference to the <CODE>sub_match </CODE>object
representing the character sequence from the start of the string being
matched/searched, to the start of the match found.</P><PRE>const_reference suffix()const;</PRE>
<B>
<P>
Effects:</B> Returns a reference to the <CODE>sub_match </CODE>object
representing the character sequence from the end of the match found to the end
of the string being matched/searched.</P><PRE>const_iterator begin()const;</PRE>
<B>
<P>
Effects:</B> Returns a starting iterator that enumerates over all the marked
sub-expression matches stored in *this.</P><PRE>const_iterator end()const;</PRE>
<B>
<P>
Effects:</B> Returns a terminating iterator that enumerates over all the
marked sub-expression matches stored in *this.</P>
<H4>match_results reformatting</H4>
<PRE>template &lt;class OutputIterator&gt;
OutputIterator format(OutputIterator out,
const string_type&amp; fmt,
<A href="match_flag_type.html">match_flag_type</A> flags = format_default);</PRE>
<B>
<P>
Requires: </B>The type OutputIterator conforms to the Output Iterator
requirements (24.1.2).</P><B>
<P>
Effects:</B> Copies the character sequence <I>[fmt.begin(), fmt.end())</I> to
OutputIterator <I>out</I>. For each format specifier or escape sequence in <I>fmt</I>,
replace that sequence with either the character(s) it represents, or the
sequence of characters within *this to which it refers. The bitmasks specified
in <I><A href="match_flag_type.html">flags</A></I> determines what <A href="format_syntax.html">
format specifiers or escape sequences are recognized</A>, by default this is
the format used by ECMA-262, ECMAScript Language Specification, Chapter 15 part
5.4.11 String.prototype.replace.</P><B>
<P>
Returns:</B> <I>out</I>.</P><PRE>string_type format(const string_type&amp; fmt,
<A href="match_flag_type.html">match_flag_type</A> flags = format_default);</PRE>
<B>
<P>
Effects:</B> Returns a copy of the string <I>fmt</I>. For each format
specifier or escape sequence in <I>fmt</I>, replace that sequence with either
the character(s) it represents, or the sequence of characters within *this to
which it refers. The bitmasks specified in <I><A href="match_flag_type.html">flags</A></I>
determines what <A href="format_syntax.html">format specifiers or escape sequences
are recognized</A>, by default this is the format used by ECMA-262,
ECMAScript Language Specification, Chapter 15 part 5.4.11
String.prototype.replace.</P><PRE>allocator_type get_allocator()const;</PRE>
<B>
<P>
Effects:</B> Returns a copy of the Allocator that was passed to the object's
constructor.</P><PRE>void swap(match_results&amp; that);</PRE>
<B>
<P>
Effects:</B> Swaps the contents of the two sequences. </P><B>
<P>
Postcondition:</B> <CODE>*this</CODE> contains the sequence of matched
sub-expressions that were in <CODE>that</CODE>, <CODE>that</CODE> contains the
sequence of matched sub-expressions that were in <CODE>*this</CODE>. </P><B>
<P>
Complexity:</B> constant time.
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -0,0 +1,184 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Partial Matches</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">Partial Matches</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<P>The <A href="match_flag_type.html">match-flag</A> <CODE>match_partial</CODE> can
be passed to the following algorithms: <A href="regex_match.html">regex_match</A>,
<A href="regex_search.html">regex_search</A>, and <A href="regex_grep.html">regex_grep</A>.
When used it indicates that partial as well as full matches should be found. A
partial match is one that matched one or more characters at the end of the text
input, but did not match all of the regular expression (although it may have
done so had more input been available). Partial matches are typically used when
either validating data input (checking each character as it is entered on the
keyboard), or when searching texts that are either too long to load into memory
(or even into a memory mapped file), or are of indeterminate length (for
example the source may be a socket or similar). Partial and full matches can be
differentiated as shown in the following table (the variable M represents an
instance of <A href="match_results.html">match_results&lt;&gt;</A> as filled in
by regex_match, regex_search or regex_grep):<BR>
</P>
<P>
<TABLE id="Table2" cellSpacing="0" cellPadding="7" width="638" border="0">
<TR>
<TD vAlign="top" width="20%">&nbsp;</TD>
<TD vAlign="top" width="20%">Result</TD>
<TD vAlign="top" width="20%">M[0].matched</TD>
<TD vAlign="top" width="20%">M[0].first</TD>
<TD vAlign="top" width="20%">M[0].second</TD>
</TR>
<TR>
<TD vAlign="top" width="20%">No match</TD>
<TD vAlign="top" width="20%">False</TD>
<TD vAlign="top" width="20%">Undefined</TD>
<TD vAlign="top" width="20%">Undefined</TD>
<TD vAlign="top" width="20%">Undefined</TD>
</TR>
<TR>
<TD vAlign="top" width="20%">Partial match</TD>
<TD vAlign="top" width="20%">True</TD>
<TD vAlign="top" width="20%">False</TD>
<TD vAlign="top" width="20%">Start of partial match.</TD>
<TD vAlign="top" width="20%">End of partial match (end of text).</TD>
</TR>
<TR>
<TD vAlign="top" width="20%">Full match</TD>
<TD vAlign="top" width="20%">True</TD>
<TD vAlign="top" width="20%">True</TD>
<TD vAlign="top" width="20%">Start of full match.</TD>
<TD vAlign="top" width="20%">End of full match.</TD>
</TR>
</TABLE>
</P>
<P>The following <A href="../example/snippets/partial_regex_match.cpp">example</A>
tests to see whether the text could be a valid credit card number, as the user
presses a key, the character entered would be added to the string being built
up, and passed to <CODE>is_possible_card_number</CODE>. If this returns true
then the text could be a valid card number, so the user interface's OK button
would be enabled. If it returns false, then this is not yet a valid card
number, but could be with more input, so the user interface would disable the
OK button. Finally, if the procedure throws an exception the input could never
become a valid number, and the inputted character must be discarded, and a
suitable error indication displayed to the user.</P>
<PRE>#include &lt;string&gt;
#include &lt;iostream&gt;
#include &lt;boost/regex.hpp&gt;
boost::regex e("(\\d{3,4})[- ]?(\\d{4})[- ]?(\\d{4})[- ]?(\\d{4})");
bool is_possible_card_number(const std::string&amp; input)
{
//
// return false for partial match, true for full match, or throw for
// impossible match based on what we have so far...
boost::match_results&lt;std::string::const_iterator&gt; what;
if(0 == boost::regex_match(input, what, e, boost::match_default | boost::match_partial))
{
// the input so far could not possibly be valid so reject it:
throw std::runtime_error("Invalid data entered - this could not possibly be a valid card number");
}
// OK so far so good, but have we finished?
if(what[0].matched)
{
// excellent, we have a result:
return true;
}
// what we have so far is only a partial match...
return false;
}</PRE>
<P>In the following <A href="../example/snippets/partial_regex_match.cpp">example</A>,
text input is taken from a stream containing an unknown amount of text; this
example simply counts the number of html tags encountered in the stream. The
text is loaded into a buffer and searched a part at a time, if a partial match
was encountered, then the partial match gets searched a second time as the
start of the next batch of text:</P>
<PRE>#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;sstream&gt;
#include &lt;string&gt;
#include &lt;boost/regex.hpp&gt;
// match some kind of html tag:
boost::regex e("&lt;[^&gt;]*&gt;");
// count how many:
unsigned int tags = 0;
// saved position of partial match:
char* next_pos = 0;
bool grep_callback(const boost::match_results&lt;char*&gt;&amp; m)
{
if(m[0].matched == false)
{
// save position and return:
next_pos = m[0].first;
}
else
++tags;
return true;
}
void search(std::istream&amp; is)
{
char buf[4096];
next_pos = buf + sizeof(buf);
bool have_more = true;
while(have_more)
{
// how much do we copy forward from last try:
unsigned leftover = (buf + sizeof(buf)) - next_pos;
// and how much is left to fill:
unsigned size = next_pos - buf;
// copy forward whatever we have left:
memcpy(buf, next_pos, leftover);
// fill the rest from the stream:
unsigned read = is.readsome(buf + leftover, size);
// check to see if we've run out of text:
have_more = read == size;
// reset next_pos:
next_pos = buf + sizeof(buf);
// and then grep:
boost::regex_grep(grep_callback,
buf,
buf + read + leftover,
e,
boost::match_default | boost::match_partial);
}
}</PRE>
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

288
doc/Attic/posix_api.html Normal file
View File

@ -0,0 +1,288 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: POSIX API Compatibility Functions</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">POSIX API Compatibility Functions</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<PRE>#include &lt;boost/cregex.hpp&gt;
<I>or</I>:
#include &lt;boost/regex.h&gt;</PRE>
<P>The following functions are available for users who need a POSIX compatible C
library, they are available in both Unicode and narrow character versions, the
standard POSIX API names are macros that expand to one version or the other
depending upon whether UNICODE is defined or not.
</P>
<P><B>Important</B>: Note that all the symbols defined here are enclosed inside
namespace <I>boost</I> when used in C++ programs, unless you use #include
&lt;boost/regex.h&gt; instead - in which case the symbols are still defined in
namespace boost, but are made available in the global namespace as well.</P>
<P>The functions are defined as:
</P>
<PRE>extern "C" {
<B>int</B> regcompA(regex_tA*, <B>const</B> <B>char</B>*, <B>int</B>);
<B>unsigned</B> <B>int</B> regerrorA(<B>int</B>, <B>const</B> regex_tA*, <B>char</B>*, <B>unsigned</B> <B>int</B>);
<B>int</B> regexecA(<B>const</B> regex_tA*, <B>const</B> <B>char</B>*, <B>unsigned</B> <B>int</B>, regmatch_t*, <B>int</B>);
<B>void</B> regfreeA(regex_tA*);
<B>int</B> regcompW(regex_tW*, <B>const</B> <B>wchar_t</B>*, <B>int</B>);
<B>unsigned</B> <B>int</B> regerrorW(<B>int</B>, <B>const</B> regex_tW*, <B>wchar_t</B>*, <B>unsigned</B> <B>int</B>);
<B>int</B> regexecW(<B>const</B> regex_tW*, <B>const</B> <B>wchar_t</B>*, <B>unsigned</B> <B>int</B>, regmatch_t*, <B>int</B>);
<B>void</B> regfreeW(regex_tW*);
#ifdef UNICODE
#define regcomp regcompW
#define regerror regerrorW
#define regexec regexecW
#define regfree regfreeW
#define regex_t regex_tW
#else
#define regcomp regcompA
#define regerror regerrorA
#define regexec regexecA
#define regfree regfreeA
#define regex_t regex_tA
#endif
}</PRE>
<P>All the functions operate on structure <B>regex_t</B>, which exposes two public
members:
</P>
<P><B>unsigned int re_nsub</B> this is filled in by <B>regcomp</B> and indicates
the number of sub-expressions contained in the regular expression.
</P>
<P><B>const TCHAR* re_endp</B> points to the end of the expression to compile when
the flag REG_PEND is set.
</P>
<P><I>Footnote: regex_t is actually a #define - it is either regex_tA or regex_tW
depending upon whether UNICODE is defined or not, TCHAR is either char or
wchar_t again depending upon the macro UNICODE.</I>
</P>
<H3>regcomp</H3>
<P><B>regcomp</B> takes a pointer to a <B>regex_t</B>, a pointer to the expression
to compile and a flags parameter which can be a combination of:
<BR>
&nbsp;
</P>
<P>
<TABLE id="Table2" cellSpacing="0" cellPadding="7" width="100%" border="0">
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">REG_EXTENDED</TD>
<TD vAlign="top" width="45%">Compiles modern regular expressions. Equivalent to
regbase::char_classes | regbase::intervals | regbase::bk_refs.</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">REG_BASIC</TD>
<TD vAlign="top" width="45%">Compiles basic (obsolete) regular expression syntax.
Equivalent to regbase::char_classes | regbase::intervals | regbase::limited_ops
| regbase::bk_braces | regbase::bk_parens | regbase::bk_refs.</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">REG_NOSPEC</TD>
<TD vAlign="top" width="45%">All characters are ordinary, the expression is a
literal string.</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">REG_ICASE</TD>
<TD vAlign="top" width="45%">Compiles for matching that ignores character case.</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">REG_NOSUB</TD>
<TD vAlign="top" width="45%">Has no effect in this library.</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">REG_NEWLINE</TD>
<TD vAlign="top" width="45%">When this flag is set a dot does not match the
newline character.</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">REG_PEND</TD>
<TD vAlign="top" width="45%">When this flag is set the re_endp parameter of the
regex_t structure must point to the end of the regular expression to compile.</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">REG_NOCOLLATE</TD>
<TD vAlign="top" width="45%">When this flag is set then locale dependent collation
for character ranges is turned off.</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">REG_ESCAPE_IN_LISTS<BR>
, , ,
</TD>
<TD vAlign="top" width="45%">When this flag is set, then escape sequences are
permitted in bracket expressions (character sets).</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">REG_NEWLINE_ALT&nbsp;</TD>
<TD vAlign="top" width="45%">When this flag is set then the newline character is
equivalent to the alternation operator |.</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">REG_PERL&nbsp;</TD>
<TD vAlign="top" width="45%">&nbsp;A shortcut for perl-like behavior: REG_EXTENDED
| REG_NOCOLLATE | REG_ESCAPE_IN_LISTS</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">REG_AWK</TD>
<TD vAlign="top" width="45%">A shortcut for awk-like behavior: REG_EXTENDED |
REG_ESCAPE_IN_LISTS</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">REG_GREP</TD>
<TD vAlign="top" width="45%">A shortcut for grep like behavior: REG_BASIC |
REG_NEWLINE_ALT</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">REG_EGREP</TD>
<TD vAlign="top" width="45%">&nbsp;A shortcut for egrep like behavior:
REG_EXTENDED | REG_NEWLINE_ALT</TD>
<TD width="5%">&nbsp;</TD>
</TR>
</TABLE>
</P>
<H3>regerror</H3>
<P>regerror takes the following parameters, it maps an error code to a human
readable string:
<BR>
</P>
<P>
<TABLE id="Table3" cellSpacing="0" cellPadding="7" width="100%" border="0">
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="50%">int code</TD>
<TD vAlign="top" width="50%">The error code.</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">const regex_t* e</TD>
<TD vAlign="top" width="50%">The regular expression (can be null).</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">char* buf</TD>
<TD vAlign="top" width="50%">The buffer to fill in with the error message.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">unsigned int buf_size</TD>
<TD vAlign="top" width="50%">The length of buf.</TD>
<TD>&nbsp;</TD>
</TR>
</TABLE>
</P>
<P>If the error code is OR'ed with REG_ITOA then the message that results is the
printable name of the code rather than a message, for example "REG_BADPAT". If
the code is REG_ATIO then <B>e</B> must not be null and <B>e-&gt;re_pend</B> must
point to the printable name of an error code, the return value is then the
value of the error code. For any other value of <B>code</B>, the return value
is the number of characters in the error message, if the return value is
greater than or equal to <B>buf_size</B> then <B>regerror</B> will have to be
called again with a larger buffer.</P>
<H3>regexec</H3>
<P><B>regexec</B> finds the first occurrence of expression <B>e</B> within string <B>buf</B>.
If <B>len</B> is non-zero then *<B>m</B> is filled in with what matched the
regular expression, <B>m[0]</B> contains what matched the whole string, <B>m[1] </B>
the first sub-expression etc, see <B>regmatch_t</B> in the header file
declaration for more details. The <B>eflags</B> parameter can be a combination
of:
<BR>
&nbsp;
</P>
<P>
<TABLE id="Table4" cellSpacing="0" cellPadding="7" width="100%" border="0">
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="50%">REG_NOTBOL</TD>
<TD vAlign="top" width="50%">Parameter <B>buf </B>does not represent the start of
a line.</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">REG_NOTEOL</TD>
<TD vAlign="top" width="50%">Parameter <B>buf</B> does not terminate at the end of
a line.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">REG_STARTEND</TD>
<TD vAlign="top" width="50%">The string searched starts at buf + pmatch[0].rm_so
and ends at buf + pmatch[0].rm_eo.</TD>
<TD>&nbsp;</TD>
</TR>
</TABLE>
</P>
<H3>regfree</H3>
<P>Finally <B>regfree</B> frees all the memory that was allocated by regcomp.
</P>
<P><I>Footnote: this is an abridged reference to the POSIX API functions, it is
provided for compatibility with other libraries, rather than an API to be used
in new code (unless you need access from a language other than C++). This
version of these functions should also happily coexist with other versions, as
the names used are macros that expand to the actual function names.</I>
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -0,0 +1,83 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Redistributables and Library Names</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">Redistributables and Library Names</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<P>If you are using Microsoft or Borland C++ and link to a dll version of the run
time library, then you will also link to one of the dll versions of boost.regex.
While these dll's are redistributable, there are no "standard" versions, so
when installing on the users PC, you should place these in a directory private
to your application, and not in the PC's directory path. Note that if you link
to a static version of your run time library, then you will also link to a
static version of boost.regex and no dll's will need to be distributed. The
possible boost.regex dll and library names are computed according to the following
formula:<BR>
</P>
<P></P>
<P>"boost_regex_"<BR>
+ BOOST_LIB_TOOLSET<BR>
+ "_"<BR>
+ BOOST_LIB_THREAD_OPT<BR>
+ BOOST_LIB_RT_OPT<BR>
+ BOOST_LIB_LINK_OPT<BR>
+ BOOST_LIB_DEBUG_OPT<BR>
<BR>
These are defined as:<BR>
<BR>
BOOST_LIB_TOOLSET: The compiler toolset name (vc6, vc7, bcb5 etc).<BR>
<BR>
BOOST_LIB_THREAD_OPT: "s" for single thread builds,<BR>
"m" for multithread builds.<BR>
<BR>
BOOST_LIB_RT_OPT: "s" for static runtime,<BR>
"d" for dynamic runtime.<BR>
<BR>
BOOST_LIB_LINK_OPT: "s" for static link,<BR>
"i" for dynamic link.<BR>
<BR>
BOOST_LIB_DEBUG_OPT: nothing for release builds,<BR>
"d" for debug builds,<BR>
"dd" for debug-diagnostic builds (_STLP_DEBUG).</P>
<P>
Note: you can disable automatic library selection by defining the symbol
BOOST_REGEX_NO_LIB when compiling, this is useful if you want to statically
link even though you're using the dll version of your run time library, or if
you need to debug boost.regex.
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -0,0 +1,45 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Class reg_expression (deprecated)</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">Class reg_expression (deprecated)</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<P>The use of class template reg_expression is deprecated: use <A href="basic_regex.html">
basic_regex</A> instead.</P>
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

55
doc/Attic/regbase.html Normal file
View File

@ -0,0 +1,55 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: regbase</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">regbase</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<P>Use of the type <code>boost::regbase</code> is now deprecated, and the type does not form a
part of the <A href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1429.htm">
regular expression standardization proposal</A>.&nbsp; This type still
exists as a base class of <code>boost::basic_regex</code>, and you can still refer to
<code>boost::regbase::constant_name</code> in your code, however for maximum portability to
other std regex implementations you should instead use either:</P>
<PRE>boost::regex_constants::constant_name</PRE>
<P>or</P>
<PRE>boost::regex::constant_name</PRE>
<P>or</P>
<PRE>boost::wregex::constant_name</PRE>
<P>
<HR>
</P>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

492
doc/Attic/regex.html Normal file
View File

@ -0,0 +1,492 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: class RegEx (deprecated)</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">class RegEx (deprecated)</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<P>The high level wrapper class RegEx is now deprecated and does not form a part
of the <A href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1429.htm">regular
expression standardization proposal</A>.&nbsp; This type still exists, and
existing code will continue to compile, however the following documentation is
unlikely to be further updated.</P>
<PRE>#include &lt;boost/cregex.hpp&gt; </PRE>
<P>The class RegEx provides a high level simplified interface to the regular
expression library, this class only handles narrow character strings, and
regular expressions always follow the "normal" syntax - that is the same as the
perl / ECMAScript synatx.
</P>
<PRE><B>typedef</B> <B>bool</B> (*GrepCallback)(<B>const</B> RegEx&amp; expression);
<B>typedef</B> <B>bool</B> (*GrepFileCallback)(<B>const</B> <B>char</B>* file, <B>const</B> RegEx&amp; expression);
<B>typedef</B> <B>bool</B> (*FindFilesCallback)(<B>const</B> <B>char</B>* file);
<B>class</B>&nbsp; RegEx
{
<B>public</B>:
&nbsp;&nbsp; RegEx();
&nbsp;&nbsp; RegEx(<B>const</B> RegEx&amp; o);
&nbsp;&nbsp; ~RegEx();
&nbsp;&nbsp; RegEx(<B>const</B> <B>char</B>* c, <B>bool</B> icase = <B>false</B>);
&nbsp;&nbsp; <STRONG>explicit</STRONG> RegEx(<B>const</B> std::string&amp; s, <B>bool</B> icase = <B>false</B>);
&nbsp;&nbsp; RegEx&amp; <B>operator</B>=(<B>const</B> RegEx&amp; o);
&nbsp;&nbsp; RegEx&amp; <B>operator</B>=(<B>const</B> <B>char</B>* p);
&nbsp;&nbsp; RegEx&amp; <B>operator</B>=(<B>const</B> std::string&amp; s);
&nbsp;&nbsp; <B>unsigned</B> <B>int</B> SetExpression(<B>const</B> <B>char</B>* p, <B>bool</B> icase = <B>false</B>);
&nbsp;&nbsp; <B>unsigned</B> <B>int</B> SetExpression(<B>const</B> std::string&amp; s, <B>bool</B> icase = <B>false</B>);
&nbsp;&nbsp; std::string Expression()<B>const</B>;
&nbsp;&nbsp; <FONT color=#000080><I>//
</I>&nbsp;&nbsp;<I>// now matching operators: </I>
&nbsp;&nbsp; <I>// </I></FONT>
&nbsp;&nbsp; <B>bool</B> Match(<B>const</B> <B>char</B>* p, <B>unsigned</B> <B>int</B> flags = match_default);
&nbsp;&nbsp; <B>bool</B> Match(<B>const</B> std::string&amp; s, <B>unsigned</B> <B>int</B> flags = match_default);
&nbsp;&nbsp; <B>bool</B> Search(<B>const</B> <B>char</B>* p, <B>unsigned</B> <B>int</B> flags = match_default);
&nbsp;&nbsp; <B>bool</B> Search(<B>const</B> std::string&amp; s, <B>unsigned</B> <B>int</B> flags = match_default);
&nbsp;&nbsp; <B>unsigned</B> <B>int</B> Grep(GrepCallback cb, <B>const</B> <B>char</B>* p, <B>unsigned</B> <B>int</B> flags = match_default);
&nbsp;&nbsp; <B>unsigned</B> <B>int</B> Grep(GrepCallback cb, <B>const</B> std::string&amp; s, <B>unsigned</B> <B>int</B> flags = match_default);
&nbsp;&nbsp; <B>unsigned</B> <B>int</B> Grep(std::vector&lt;std::string&gt;&amp; v, <B>const</B> <B>char</B>* p, <B>unsigned</B> <B>int</B> flags = match_default);
&nbsp;&nbsp; <B>unsigned</B> <B>int</B> Grep(std::vector&lt;std::string&gt;&amp; v, <B>const</B> std::string&amp; s, <B>unsigned</B> <B>int</B> flags = match_default);
&nbsp;&nbsp; <B>unsigned</B> <B>int</B> Grep(std::vector&lt;<B>unsigned</B> <B>int</B>&gt;&amp; v, <B>const</B> <B>char</B>* p, <B>unsigned</B> <B>int</B> flags = match_default);
&nbsp;&nbsp; <B>unsigned</B> <B>int</B> Grep(std::vector&lt;<B>unsigned</B> <B>int</B>&gt;&amp; v, <B>const</B> std::string&amp; s, <B>unsigned</B> <B>int</B> flags = match_default);
&nbsp;&nbsp; <B>unsigned</B> <B>int</B> GrepFiles(GrepFileCallback cb, <B>const</B> <B>char</B>* files, <B>bool</B> recurse = <B>false</B>, <B>unsigned</B> <B>int</B> flags = match_default);
&nbsp;&nbsp; <B>unsigned</B> <B>int</B> GrepFiles(GrepFileCallback cb, <B>const</B> std::string&amp; files, <B>bool</B> recurse = <B>false</B>, <B>unsigned</B> <B>int</B> flags = match_default);
&nbsp;&nbsp; <B>unsigned</B> <B>int</B> FindFiles(FindFilesCallback cb, <B>const</B> <B>char</B>* files, <B>bool</B> recurse = <B>false</B>, <B>unsigned</B> <B>int</B> flags = match_default);
&nbsp;&nbsp; <B>unsigned</B> <B>int</B> FindFiles(FindFilesCallback cb, <B>const</B> std::string&amp; files, <B>bool</B> recurse = <B>false</B>, <B>unsigned</B> <B>int</B> flags = match_default);
&nbsp;&nbsp; std::string Merge(<B>const</B> std::string&amp; in, <B>const</B> std::string&amp; fmt, <B>bool</B> copy = <B>true</B>, <B>unsigned</B> <B>int</B> flags = match_default);
&nbsp;&nbsp; std::string Merge(<B>const</B> char* in, <B>const</B> char* fmt, <B>bool</B> copy = <B>true</B>, <B>unsigned int </B>flags = match_default);
&nbsp;&nbsp; <B>unsigned</B> Split(std::vector&lt;std::string&gt;&amp; v, std::string&amp; s, <B>unsigned</B> flags = match_default, <B>unsigned</B> max_count = ~0);
&nbsp;&nbsp; <FONT color=#000080><I>//
</I>&nbsp;&nbsp; <I>// now operators for returning what matched in more detail:
</I>&nbsp;&nbsp; <I>//
</I></FONT>&nbsp;&nbsp; <B>unsigned</B> <B>int</B> Position(<B>int</B> i = 0)<B>const</B>;
&nbsp;&nbsp; <B>unsigned</B> <B>int</B> Length(<B>int</B> i = 0)<B>const</B>;
<STRONG>bool</STRONG> Matched(<STRONG>int</STRONG> i = 0)<STRONG>const</STRONG>;
&nbsp;&nbsp; <B>unsigned</B> <B>int</B> Line()<B>const</B>;
&nbsp;&nbsp; <B>unsigned int</B> Marks() const;
&nbsp;&nbsp; std::string What(<B>int</B> i)<B>const</B>;
&nbsp;&nbsp; std::string <B>operator</B>[](<B>int</B> i)<B>const</B> ;
<STRONG>static const unsigned int</STRONG> npos;
}; &nbsp; &nbsp; </PRE>
<P>Member functions for class RegEx are defined as follows:
<BR>
&nbsp;
</P>
<P>
<TABLE id="Table2" cellSpacing="0" cellPadding="7" width="100%" border="0">
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%">RegEx();</TD>
<TD vAlign="top" width="42%">Default constructor, constructs an instance of RegEx
without any valid expression.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%">RegEx(<B>const</B> RegEx&amp; o);</TD>
<TD vAlign="top" width="42%">Copy constructor, all the properties of parameter <I>o</I>
are copied.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%">RegEx(<B>const</B> <B>char</B>* c, <B>bool</B> icase
= <B>false</B>);</TD>
<TD vAlign="top" width="42%">Constructs an instance of RegEx, setting the
expression to <I>c</I>, if <I>icase</I> is <I>true</I> then matching is
insensitive to case, otherwise it is sensitive to case. Throws <I>bad_expression</I>
on failure.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%">RegEx(<B>const</B> std::string&amp; s, <B>bool</B> icase
= <B>false</B>);</TD>
<TD vAlign="top" width="42%">Constructs an instance of RegEx, setting the
expression to <I>s</I>, if <I>icase </I>is <I>true</I> then matching is
insensitive to case, otherwise it is sensitive to case. Throws <I>bad_expression</I>
on failure.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%">RegEx&amp; <B>operator</B>=(<B>const</B> RegEx&amp;
o);</TD>
<TD vAlign="top" width="42%">Default assignment operator.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%">RegEx&amp; <B>operator</B>=(<B>const</B> <B>char</B>*
p);</TD>
<TD vAlign="top" width="42%">Assignment operator, equivalent to calling <I>SetExpression(p,
false).</I> Throws <I>bad_expression</I> on failure.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%">RegEx&amp; <B>operator</B>=(<B>const</B> std::string&amp;
s);</TD>
<TD vAlign="top" width="42%">Assignment operator, equivalent to calling <I>SetExpression(s,
false).</I> Throws <I>bad_expression</I> on failure.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>unsigned</B> <B>int</B> SetExpression(<B>constchar</B>*
p, <B>bool</B> icase = <B>false</B>);</TD>
<TD vAlign="top" width="42%">Sets the current expression to <I>p</I>, if <I>icase</I>
is <I>true</I> then matching is insensitive to case, otherwise it is sensitive
to case. Throws <I>bad_expression</I> on failure.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>unsigned</B> <B>int</B> SetExpression(<B>const</B>
std::string&amp; s, <B>bool</B> icase = <B>false</B>);</TD>
<TD vAlign="top" width="42%">Sets the current expression to <I>s</I>, if <I>icase</I>
is <I>true</I> then matching is insensitive to case, otherwise it is sensitive
to case. Throws <I>bad_expression</I> on failure.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%">std::string Expression()<B>const</B>;</TD>
<TD vAlign="top" width="42%">Returns a copy of the current regular expression.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>bool</B> Match(<B>const</B> <B>char</B>* p, <B>unsigned</B>
<B>int</B> flags = match_default);</TD>
<TD vAlign="top" width="42%">Attempts to match the current expression against the
text <I>p</I> using the match flags <I>flags</I> - see <A href="match_flag_type.html">
match flags</A>. Returns <I>true</I> if the expression matches the whole of
the input string.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>bool</B> Match(<B>const</B> std::string&amp; s, <B>unsigned</B>
<B>int</B> flags = match_default) ;</TD>
<TD vAlign="top" width="42%">Attempts to match the current expression against the
text <I>s</I> using the match flags <I>flags</I> - see <A href="match_flag_type.html">
match flags</A>. Returns <I>true</I> if the expression matches the whole of
the input string.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>bool</B> Search(<B>const</B> <B>char</B>* p, <B>unsigned</B>
<B>int</B> flags = match_default);</TD>
<TD vAlign="top" width="42%">Attempts to find a match for the current expression
somewhere in the text <I>p</I> using the match flags <I>flags </I>- see <A href="match_flag_type.html">
match flags</A>. Returns <I>true</I> if the match succeeds.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>bool</B> Search(<B>const</B> std::string&amp; s, <B>unsigned</B>
<B>int</B> flags = match_default) ;</TD>
<TD vAlign="top" width="42%">Attempts to find a match for the current expression
somewhere in the text <I>s</I> using the match flags <I>flags </I>- see <A href="match_flag_type.html">
match flags</A>. Returns <I>true</I> if the match succeeds.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>unsigned</B> <B>int</B> Grep(GrepCallback cb, <B>const</B>
<B>char</B>* p, <B>unsigned</B> <B>int</B> flags = match_default);</TD>
<TD vAlign="top" width="42%">Finds all matches of the current expression in the
text <I>p</I> using the match flags <I>flags </I>- see <A href="match_flag_type.html">
match flags</A>. For each match found calls the call-back function <I>cb</I>
as: cb(*this);
<P>If at any stage the call-back function returns false then the grep operation
terminates, otherwise continues until no further matches are found. Returns the
number of matches found.</P>
</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>unsigned</B> <B>int</B> Grep(GrepCallback cb, <B>const</B>
std::string&amp; s, <B>unsigned</B> <B>int</B> flags = match_default);</TD>
<TD vAlign="top" width="42%">Finds all matches of the current expression in the
text <I>s</I> using the match flags <I>flags </I>- see <A href="match_flag_type.html">
match flags</A>. For each match found calls the call-back function <I>cb</I>
as: cb(*this);
<P>If at any stage the call-back function returns false then the grep operation
terminates, otherwise continues until no further matches are found. Returns the
number of matches found.
</P>
</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>unsigned</B> <B>int</B> Grep(std::vector&lt;std::string&gt;&amp;
v, <B>const</B> <B>char</B>* p, <B>unsigned</B> <B>int</B> flags =
match_default);</TD>
<TD vAlign="top" width="42%">Finds all matches of the current expression in the
text <I>p</I> using the match flags <I>flags </I>- see <A href="match_flag_type.html">
match flags</A>. For each match pushes a copy of what matched onto <I>v</I>.
Returns the number of matches found.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>unsigned</B> <B>int</B> Grep(std::vector&lt;std::string&gt;&amp;
v, <B>const</B> std::string&amp; s, <B>unsigned</B> <B>int</B> flags =
match_default);</TD>
<TD vAlign="top" width="42%">Finds all matches of the current expression in the
text <I>s</I> using the match flags <I>flags </I>- see <A href="match_flag_type.html">
match flags</A>. For each match pushes a copy of what matched onto <I>v</I>.
Returns the number of matches found.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>unsigned</B> <B>int</B> Grep(std::vector&lt;<B>unsigned
int</B>&gt;&amp; v, <B>const</B> <B>char</B>* p, <B>unsigned</B> <B>int</B> flags
= match_default);</TD>
<TD vAlign="top" width="42%">Finds all matches of the current expression in the
text <I>p</I> using the match flags <I>flags </I>- see <A href="match_flag_type.html">
match flags</A>. For each match pushes the starting index of what matched
onto <I>v</I>. Returns the number of matches found.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>unsigned</B> <B>int</B> Grep(std::vector&lt;<B>unsigned
int</B>&gt;&amp; v, <B>const</B> std::string&amp; s, <B>unsigned</B> <B>int</B>
flags = match_default);</TD>
<TD vAlign="top" width="42%">Finds all matches of the current expression in the
text <I>s</I> using the match flags <I>flags </I>- see <A href="match_flag_type.html">
match flags</A>. For each match pushes the starting index of what matched
onto <I>v</I>. Returns the number of matches found.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>unsigned</B> <B>int</B> GrepFiles(GrepFileCallback
cb, <B>const</B> <B>char</B>* files, <B>bool</B> recurse = <B>false</B>, <B>unsigned</B>
<B>int</B> flags = match_default);</TD>
<TD vAlign="top" width="42%">Finds all matches of the current expression in the
files <I>files</I> using the match flags <I>flags </I>- see <A href="match_flag_type.html">
match flags</A>. For each match calls the call-back function cb.&nbsp;
<P>If the call-back returns false then the algorithm returns without considering
further matches in the current file, or any further files.&nbsp;
</P>
<P>The parameter <I>files</I> can include wild card characters '*' and '?', if the
parameter <I>recurse</I> is true then searches sub-directories for matching
file names.&nbsp;
</P>
<P>Returns the total number of matches found.</P>
<P>May throw an exception derived from std::runtime_error if file io fails.</P>
</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>unsigned</B> <B>int</B> GrepFiles(GrepFileCallback
cb, <B>const</B> std::string&amp; files, <B>bool</B> recurse = <B>false</B>, <B>unsigned</B>
<B>int</B> flags = match_default);</TD>
<TD vAlign="top" width="42%">Finds all matches of the current expression in the
files <I>files</I> using the match flags <I>flags </I>- see <A href="match_flag_type.html">
match flags</A>. For each match calls the call-back function cb.&nbsp;
<P>If the call-back returns false then the algorithm returns without considering
further matches in the current file, or any further files.&nbsp;
</P>
<P>The parameter <I>files</I> can include wild card characters '*' and '?', if the
parameter <I>recurse</I> is true then searches sub-directories for matching
file names.&nbsp;
</P>
<P>Returns the total number of matches found.</P>
<P>May throw an exception derived from std::runtime_error if file io fails.</P>
</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>unsigned</B> <B>int</B> FindFiles(FindFilesCallback
cb, <B>const</B> <B>char</B>* files, <B>bool</B> recurse = <B>false</B>, <B>unsigned</B>
<B>int</B> flags = match_default);</TD>
<TD vAlign="top" width="42%">Searches <I>files</I> to find all those which contain
at least one match of the current expression using the match flags <I>flags </I>
- see <A href="match_flag_type.html">match flags</A>. For each
matching file calls the call-back function cb.&nbsp;
<P>If the call-back returns false then the algorithm returns without considering
any further files.&nbsp;
</P>
<P>The parameter <I>files</I> can include wild card characters '*' and '?', if the
parameter <I>recurse</I> is true then searches sub-directories for matching
file names.&nbsp;
</P>
<P>Returns the total number of files found.</P>
<P>May throw an exception derived from std::runtime_error if file io fails.</P>
</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>unsigned</B> <B>int</B> FindFiles(FindFilesCallback
cb, <B>const</B> std::string&amp; files, <B>bool</B> recurse = <B>false</B>, <B>unsigned</B>
<B>int</B> flags = match_default);</TD>
<TD vAlign="top" width="42%">Searches <I>files</I> to find all those which contain
at least one match of the current expression using the match flags <I>flags </I>
- see <A href="match_flag_type.html">match flags</A>. For each
matching file calls the call-back function cb.&nbsp;
<P>If the call-back returns false then the algorithm returns without considering
any further files.&nbsp;
</P>
<P>The parameter <I>files</I> can include wild card characters '*' and '?', if the
parameter <I>recurse</I> is true then searches sub-directories for matching
file names.&nbsp;
</P>
<P>Returns the total number of files found.</P>
<P>May throw an exception derived from std::runtime_error if file io fails.</P>
</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%">std::string Merge(<B>const</B> std::string&amp; in, <B>const</B>
std::string&amp; fmt, <B>bool</B> copy = <B>true</B>, <B>unsigned</B> <B>int</B>
flags = match_default);</TD>
<TD vAlign="top" width="42%">Performs a search and replace operation: searches
through the string <I>in</I> for all occurrences of the current expression, for
each occurrence replaces the match with the format string <I>fmt</I>. Uses <I>flags</I>
to determine what gets matched, and how the format string should be treated. If <I>
copy</I> is true then all unmatched sections of input are copied unchanged
to output, if the flag <EM>format_first_only</EM> is set then only the first
occurance of the pattern found is replaced. Returns the new string. See <A href="format_synatx.html">
also format string syntax</A>, <A href="match_flag_type.html">match
flags</A> and <A href="match_flag_type.html">format flags</A>.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%">std::string Merge(<B>const</B> char* in, <B>const</B>
char* fmt, <B>bool</B> copy = <B>true</B>, <B>unsigned int </B>flags =
match_default);</TD>
<TD vAlign="top" width="42%">Performs a search and replace operation: searches
through the string <I>in</I> for all occurrences of the current expression, for
each occurrence replaces the match with the format string <I>fmt</I>. Uses <I>flags</I>
to determine what gets matched, and how the format string should be treated. If <I>
copy</I> is true then all unmatched sections of input are copied unchanged
to output, if the flag <EM>format_first_only</EM> is set then only the first
occurance of the pattern found is replaced. Returns the new string. See <A href="format_synatx.html">
also format string syntax</A>, <A href="match_flag_type.html">match
flags</A> and <A href="match_flag_type.html">format flags</A>.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top"><B>unsigned</B> Split(std::vector&lt;std::string&gt;&amp; v,
std::string&amp; s, <B>unsigned</B> flags = match_default, <B>unsigned</B> max_count
= ~0);</TD>
<TD vAlign="top">Splits the input string and pushes each one onto the vector. If
the expression contains no marked sub-expressions, then one string is outputted
for each section of the input that does not match the expression. If the
expression does contain marked sub-expressions, then outputs one string for
each marked sub-expression each time a match occurs. Outputs no more than <I>max_count
</I>strings. Before returning, deletes from the input string <I>s</I> all of
the input that has been processed (all of the string if <I>max_count</I> was
not reached). Returns the number of strings pushed onto the vector.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>unsigned</B> <B>int</B> Position(<B>int</B> i = 0)<B>const</B>;</TD>
<TD vAlign="top" width="42%">Returns the position of what matched sub-expression <I>i</I>.
If <I>i = 0</I> then returns the position of the whole match. Returns
RegEx::npos if the supplied index is invalid, or if the specified
sub-expression did not participate in the match.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>unsigned</B> <B>int</B> Length(<B>int</B> i = 0)<B>const</B>;</TD>
<TD vAlign="top" width="42%">Returns the length of what matched sub-expression <I>i</I>.
If <I>i = 0</I> then returns the length of the whole match. Returns RegEx::npos
if the supplied index is invalid, or if the specified sub-expression did not
participate in the match.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD><STRONG>bool</STRONG> Matched(<STRONG>int</STRONG> i = 0)<STRONG>const</STRONG>;</TD>
<TD>Returns true if sub-expression <EM>i</EM> was matched, false otherwise.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>unsigned</B> <B>int</B> Line()<B>const</B>;</TD>
<TD vAlign="top" width="42%">Returns the line on which the match occurred, indexes
start from 1 not zero, if no match occurred then returns RegEx::npos.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>unsigned int</B> Marks() const;</TD>
<TD vAlign="top" width="42%">Returns the number of marked sub-expressions
contained in the expression. Note that this includes the whole match
(sub-expression zero), so the value returned is always &gt;= 1.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%">std::string What(<B>int</B> i)<B>const</B>;</TD>
<TD vAlign="top" width="42%">Returns a copy of what matched sub-expression <I>i</I>.
If <I>i = 0</I> then returns a copy of the whole match. Returns a null string
if the index is invalid or if the specified sub-expression did not participate
in a match.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%">std::string <B>operator</B>[](<B>int</B> i)<B>const</B>
;</TD>
<TD vAlign="top" width="42%">Returns <I>what(i);</I>
<P>Can be used to simplify access to sub-expression matches, and make usage more
perl-like.</P>
</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
</TABLE>
</P>
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

165
doc/Attic/regex_format.html Normal file
View File

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

379
doc/Attic/regex_grep.html Normal file
View File

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

325
doc/Attic/regex_match.html Normal file
View File

@ -0,0 +1,325 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Algorithm regex_match</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">Algorithm regex_match</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<H3>Contents</H3>
<dl class="index">
<dt><a href="#synopsis">Synopsis</a></dt>
<dt><a href="#description">Description</a></dt>
<dt><a href="#examples">Examples</a></dt>
</dl>
<H3><A name="synopsis"></A>Synopsis</H3>
<PRE><A name=query_match></A>#include &lt;<A href="../../boost/regex.hpp">boost/regex.hpp</A>&gt; </PRE>
<P>The algorithm regex _match determines whether a given regular expression
matches a given sequence denoted by a pair of bidirectional-iterators, the
algorithm is defined as follows, <EM><FONT color="red">note that the result is true
only if the expression matches the whole of the input sequence</FONT></EM>,
the main use of this function is data input validation.
<PRE>template &lt;class BidirectionalIterator, class Allocator, class charT,
class traits, class Allocator2&gt;
bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
<A href="match_results.html">match_results</A>&lt;BidirectionalIterator, Allocator&gt;&amp; m,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</A> flags = match_default);
template &lt;class BidirectionalIterator, class charT, class traits, class Allocator2&gt;
bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</a> flags = match_default);
template &lt;class charT, class Allocator, class traits, class Allocator2&gt;
bool regex_match(const charT* str, <A href="match_results.html">match_results</A>&lt;const charT*, Allocator&gt;&amp; m,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</A> flags = match_default);
template &lt;class ST, class SA, class Allocator, class charT,
class traits, class Allocator2&gt;
bool regex_match(const basic_string&lt;charT, ST, SA&gt;&amp; s,
<A href="match_results.html">match_results</A>&lt;typename basic_string&lt;charT, ST, SA&gt;::const_iterator, Allocator&gt;&amp; m,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</A> flags = match_default);
template &lt;class charT, class traits, class Allocator2&gt;
bool regex_match(const charT* str,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</A> flags = match_default);
template &lt;class ST, class SA, class charT, class traits, class Allocator2&gt;
bool regex_match(const basic_string&lt;charT, ST, SA&gt;&amp; s,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</A> flags = match_default);
</PRE>
<H3><A name="description"></A>Description</H3>
<PRE>template &lt;class BidirectionalIterator, class Allocator, class charT,
class traits, class Allocator2&gt;
bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
<A href="match_results.html">match_results</A>&lt;BidirectionalIterator, Allocator&gt;&amp; m,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</A> flags = match_default);</PRE>
<B>
<P>
Requires:</B> Type BidirectionalIterator meets the requirements of a
Bidirectional Iterator (24.1.4).</P>
<B>
<P>
Effects: </B>Determines whether there is an exact match between the regular
expression <I>e</I>, and all of the character sequence [first, last), parameter <I>
flags</I> is used to <A href="match_flag_type.html">control how the expression
is matched</A> against the character sequence. Returns true if such a match
exists, false otherwise.</P><B>
<P>
Postconditions: </B>If the function returns false, then the effect on
parameter <I>m</I> is undefined, otherwise the effects on parameter <I>m</I> are
given in the table:</P> <I>
<P>
<DIV align="center">
<P></P>
</I>
<P align="center">
<CENTER>
<TABLE id="Table2" cellSpacing="1" cellPadding="7" width="624" border="1">
<TBODY>
<TR>
<TD vAlign="top" width="50%"><B>
<P>
Element</B>
</P>
</TD>
<TD vAlign="top" width="50%"><B>
<P>
Value</B> </P></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.size()</P>
</TD>
<TD vAlign="top" width="50%">
<P>e.mark_count()</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.empty()</P>
</TD>
<TD vAlign="top" width="50%">
<P>false</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.prefix().first</P>
</TD>
<TD vAlign="top" width="50%">
<P>first</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.prefix().last</P>
</TD>
<TD vAlign="top" width="50%">
<P>first</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.prefix().matched</P>
</TD>
<TD vAlign="top" width="50%">
<P>false</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.suffix().first</P>
</TD>
<TD vAlign="top" width="50%">
<P>last</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.suffix().last</P>
</TD>
<TD vAlign="top" width="50%">
<P>last</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.suffix().matched</P>
</TD>
<TD vAlign="top" width="50%">
<P>false</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[0].first</P>
</TD>
<TD vAlign="top" width="50%">
<P>first</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[0].second</P>
</TD>
<TD vAlign="top" width="50%">
<P>last</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[0].matched</P>
</TD>
<TD vAlign="top" width="50%"><CODE>
<P>
true</CODE> if a full match was found, and <CODE>false</CODE> if it was a
partial match (found as a result of the <CODE>match_partial</CODE> flag being
set).</P></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[n].first</P>
</TD>
<TD vAlign="top" width="50%">
<P>For all integers n &lt; m.size(), the start of the sequence that matched
sub-expression <I>n</I>. Alternatively, if sub-expression n did not participate
in the match, then <I>last</I>.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[n].second</P>
</TD>
<TD vAlign="top" width="50%">
<P>For all integers n &lt; m.size(), the end of the sequence that matched
sub-expression <I>n</I>. Alternatively, if sub-expression n did not participate
in the match, then <I>last</I>.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[n].matched</P>
</TD>
<TD vAlign="top" width="50%">
<P>For all integers n &lt; m.size(), true if sub-expression <I>n</I> participated
in the match, false otherwise.</P>
<P></P>
</TD>
</TR>
</TBODY></TD></TR></TABLE></CENTER>
<P></P>
</DIV><PRE>template &lt;class BidirectionalIterator, class charT, class traits, class Allocator2&gt;
bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</A> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Behaves "as if" by constructing an instance of <CODE><A href="match_results.html">
match_results</A>&lt;</CODE>BidirectionalIterator<CODE>&gt; what</CODE>,
and then returning the result of <CODE>regex_match(first, last, what, e, flags)</CODE>.</P><PRE>template &lt;class charT, class Allocator, class traits, class Allocator2&gt;
bool regex_match(const charT* str, <A href="match_results.html">match_results</A>&lt;const charT*, Allocator&gt;&amp; m,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</A> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>regex_match(str, str +
char_traits&lt;charT&gt;::length(str), m, e, flags)</CODE>.</P><PRE>template &lt;class ST, class SA, class Allocator, class charT,
class traits, class Allocator2&gt;
bool regex_match(const basic_string&lt;charT, ST, SA&gt;&amp; s,
<A href="match_results.html">match_results</A>&lt;typename basic_string&lt;charT, ST, SA&gt;::const_iterator, Allocator&gt;&amp; m,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</A> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>regex_match(s.begin(), s.end(), m, e,
flags)</CODE>.</P><PRE>template &lt;class charT, class traits, class Allocator2&gt;
bool regex_match(const charT* str,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</A> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>regex_match(str, str +
char_traits&lt;charT&gt;::length(str), e, flags)</CODE>.</P><PRE>template &lt;class ST, class SA, class charT, class traits, class Allocator2&gt;
bool regex_match(const basic_string&lt;charT, ST, SA&gt;&amp; s,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</A> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>regex_match(s.begin(), s.end(), e,
flags)</CODE>.
<H3><A name="examples"></A>Examples</H3>
<P>The following <A href="../example/snippets/regex_match_example.cpp">example</A>
processes an ftp response:
<P></P>
<PRE><FONT color=#008000>#include &lt;stdlib.h&gt;
#include &lt;boost/regex.hpp&gt;
#include &lt;string&gt;
#include &lt;iostream&gt;
</FONT><B>using namespace</B> boost;
regex expression(<FONT color=#000080>"([0-9]+)(\\-| |$)(.*)"</FONT>);
<FONT color=#000080><I>// process_ftp:
// on success returns the ftp response code, and fills
// msg with the ftp response message.
</I></FONT><B>int</B> process_ftp(<B>const</B> <B>char</B>* response, std::string* msg)
{
&nbsp;&nbsp; cmatch what;
&nbsp;&nbsp; <B>if</B>(regex_match(response, what, expression))
&nbsp;&nbsp; {
<FONT color=#000080>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <I>// what[0] contains the whole string
</I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <I>// what[1] contains the response code
</I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <I>// what[2] contains the separator character
</I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <I>// what[3] contains the text message.
</I></FONT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>if</B>(msg)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; msg-&gt;assign(what[3].first, what[3].second);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>return</B> std::atoi(what[1].first);
&nbsp;&nbsp; }
<FONT color=#000080>&nbsp;&nbsp; <I>// failure did not match
</I></FONT>&nbsp;&nbsp; <B>if</B>(msg)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; msg-&gt;erase();
&nbsp;&nbsp; <B>return</B> -1;
}
<P>
<HR></PRE>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -0,0 +1,46 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Algorithm regex_merge (deprecated)</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">Algorithm regex_merge (deprecated)</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<P>Algorithm regex_merge has been renamed <A href="regex_replace.html">regex_replace</A>,
existing code will continue to compile, but newcode should use <A href="regex_replace.html">
regex_replace</A> instead.</P>
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -0,0 +1,208 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Algorithm regex_replace</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<LINK href="../../../boost.css" type="text/css" rel="stylesheet"></head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td vAlign="top" width="300">
<h3><A href="../../../index.htm"><IMG height="86" alt="C++ Boost" src="../../../c++boost.gif" width="277" border="0"></A></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">Algorithm regex_replace</H2>
</TD>
<td width="50">
<h3><A href="index.html"><IMG height="45" alt="Boost.Regex Index" src="uarrow.gif" width="43" border="0"></A></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<H3>Contents</H3>
<dl class="index">
<dt><A href="#synopsis">Synopsis</A> <dt><a href="#description">Description</a> <dt><A href="#examples">
Examples</A></dt></dl>
<H3><A name="synopsis"></A>Synopsis</H3>
<PRE>#include &lt;<A href="../../../boost/regex.hpp">boost/regex.hpp</A>&gt; </PRE>
<P>The algorithm regex_replace&nbsp;searches&nbsp;through&nbsp;a string finding
all the matches to the regular expression: for each match it then calls <A href="match_results.html">
match_results::format</A> to format the string and sends the result to the
output iterator. Sections of text that do not match are copied to the output
unchanged only if the <EM>flags</EM> parameter does not have the flag <A href="match_flags.html">
format_no_copy</A> set. If the flag <A href="match_flags.html">format_first_only</A>
is set then only the first occurance is replaced rather than all
occurrences.&nbsp;<PRE>template &lt;class OutputIterator, class BidirectionalIterator, class traits,
class Allocator, class charT&gt;
OutputIterator regex_replace(OutputIterator out,
BidirectionalIterator first,
BidirectionalIterator last,
const basic_regex&lt;charT, traits, Allocator&gt;&amp; e,
const basic_string&lt;charT&gt;&amp; fmt,
match_flag_type flags = match_default);
template &lt;class traits, class Allocator, class charT&gt;
basic_string&lt;charT&gt; regex_replace(const basic_string&lt;charT&gt;&amp; s,
const basic_regex&lt;charT, traits, Allocator&gt;&amp; e,
const basic_string&lt;charT&gt;&amp; fmt,
match_flag_type flags = match_default);
</PRE>
<H3><A name="description"></A>Description</H3>
<PRE>template &lt;class OutputIterator, class BidirectionalIterator, class traits,
class Allocator, class charT&gt;
OutputIterator regex_replace(OutputIterator out,
BidirectionalIterator first,
BidirectionalIterator last,
const basic_regex&lt;charT, traits, Allocator&gt;&amp; e,
const basic_string&lt;charT&gt;&amp; fmt,
match_flag_type flags = match_default);</PRE>
<B>
<P>
Effects:</B> Finds all the non-overlapping matches <I>m</I> of type <CODE>match_results&lt;BidirectionalIterator&gt;
</CODE>that occur within the sequence [first, last). If no such matches are
found and <CODE>!(flags &amp; format_no_copy)</CODE> then calls <CODE>std::copy(first,
last, out)</CODE>. Otherwise, for each match found, if <CODE>!(flags &amp;
format_no_copy)</CODE> calls <CODE>std::copy(m.prefix().first, m.prefix().last,
out)</CODE>, and then calls <CODE>m.format(out, fmt, flags)</CODE>. Finally
if <CODE>!(flags &amp; format_no_copy)</CODE> calls <CODE>std::copy(last_m.suffix().first,
last_m,suffix().last, out) </CODE>where <CODE>last_m</CODE> is a copy of the
last match found. If <CODE>flags &amp; format_first_only</CODE> is non-zero
then only the first match found is replaced.</P>
<B>
<P>
Returns:</B> <CODE>out</CODE>. </P><PRE>template &lt;class traits, class Allocator, class charT&gt;
basic_string&lt;charT&gt; regex_replace(const basic_string&lt;charT&gt;&amp; s,
const basic_regex&lt;charT, traits, Allocator&gt;&amp; e,
const basic_string&lt;charT&gt;&amp; fmt,
match_flag_type flags = match_default);</PRE>
<B>
<P>
Effects:</B> Constructs an object <CODE>basic_string&lt;charT&gt; result</CODE>,
calls <CODE>regex_replace(back_inserter(result), s.begin(), s.end(), e, fmt,
flags)</CODE>, and then returns <CODE>result</CODE>.
<H3><A name="examples"></A>Examples</H3>
<P>The following <A href="../example/snippets/regex_replace_example.cpp">example</A> takes
C/C++ source code as input, and outputs syntax highlighted HTML code.</P>
<P></P>
<PRE><FONT color=#008080>#include &lt;fstream&gt;
#include &lt;sstream&gt;
#include &lt;string&gt;
#include &lt;iterator&gt;
#include &lt;boost/regex.hpp&gt;
#include &lt;fstream&gt;
#include &lt;iostream&gt;
</FONT>
<FONT color=#000080><I>// purpose:
// takes the contents of a file and transform to
// syntax highlighted code in html format
</I></FONT>
boost::regex e1, e2;
<B>extern</B> <B>const</B> <B>char</B>* expression_text;
<B>extern</B> <B>const</B> <B>char</B>* format_string;
<B>extern</B> <B>const</B> <B>char</B>* pre_expression;
<B>extern</B> <B>const</B> <B>char</B>* pre_format;
<B>extern</B> <B>const</B> <B>char</B>* header_text;
<B>extern</B> <B>const</B> <B>char</B>* footer_text;
<B>void</B> load_file(std::string&amp; s, std::istream&amp; is)
{
s.erase();
s.reserve(is.rdbuf()-&gt;in_avail());
<B>char</B> c;
<B>while</B>(is.get(c))
{
<B>if</B>(s.capacity() == s.size())
s.reserve(s.capacity() * <FONT color=#000080>3</FONT>);
s.append(<FONT color=#000080>1</FONT>, c);
}
}
<B>int</B> main(<B>int</B> argc, <B>const</B> <B>char</B>** argv)
{
try{
e1.assign(expression_text);
e2.assign(pre_expression);
<B>for</B>(<B>int</B> i = <FONT color=#000080>1</FONT>; i &lt; argc; ++i)
{
std::cout &lt;&lt; <FONT color=#0000ff>"Processing file "</FONT> &lt;&lt; argv[i] &lt;&lt; std::endl;
std::ifstream fs(argv[i]);
std::string in;
load_file(in, fs);
std::string out_name(std::string(argv[i]) + std::string(<FONT color=#0000ff>".htm"</FONT>));
std::ofstream os(out_name.c_str());
os &lt;&lt; header_text;
<FONT color=#000080><I>// strip '&lt;' and '&gt;' first by outputting to a
</I></FONT> <FONT color=#000080><I>// temporary string stream
</I></FONT> std::ostringstream t(std::ios::out | std::ios::binary);
std::ostream_iterator&lt;<B>char</B>, <B>char</B>&gt; oi(t);
boost::regex_replace(oi, in.begin(), in.end(), e2, pre_format);
<FONT color=#000080><I>// then output to final output stream
</I></FONT> <FONT color=#000080><I>// adding syntax highlighting:
</I></FONT> std::string s(t.str());
std::ostream_iterator&lt;<B>char</B>, <B>char</B>&gt; out(os);
boost::regex_replace(out, s.begin(), s.end(), e1, format_string);
os &lt;&lt; footer_text;
}
}
<STRONG>catch</STRONG>(...)
{ <STRONG>return</STRONG> -1; }
<B>return</B> <FONT color=#000080>0</FONT>;
}
<B>extern</B> <B>const</B> <B>char</B>* pre_expression = <FONT color=#0000ff>"(&lt;)|(&gt;)|\\r"</FONT>;
<B>extern</B> <B>const</B> <B>char</B>* pre_format = <FONT color=#0000ff>"(?1&lt;)(?2&gt;)"</FONT>;
<B>const</B> <B>char</B>* expression_text = <FONT color=#000080><I>// preprocessor directives: index 1
</I></FONT> <FONT color=#0000ff>"(^[[:blank:]]*#(?:[^\\\\\\n]|\\\\[^\\n[:punct:][:word:]]*[\\n[:punct:][:word:]])*)|"
</FONT> <FONT color=#000080><I>// comment: index 2
</I></FONT> <FONT color=#0000ff>"(//[^\\n]*|/\\*.*?\\*/)|"
</FONT> <FONT color=#000080><I>// literals: index 3
</I></FONT> <FONT color=#0000ff>"\\&lt;([+-]?(?:(?:0x[[:xdigit:]]+)|(?:(?:[[:digit:]]*\\.)?[[:digit:]]+(?:[eE][+-]?[[:digit:]]+)?))u?(?:(?:int(?:8|16|32|64))|L)?)\\&gt;|"
</FONT> <FONT color=#000080><I>// string literals: index 4
</I></FONT> <FONT color=#0000ff>"('(?:[^\\\\']|\\\\.)*'|\"(?:[^\\\\\"]|\\\\.)*\")|"
</FONT> <FONT color=#000080><I>// keywords: index 5
</I></FONT> <FONT color=#0000ff>"\\&lt;(__asm|__cdecl|__declspec|__export|__far16|__fastcall|__fortran|__import"
</FONT> <FONT color=#0000ff>"|__pascal|__rtti|__stdcall|_asm|_cdecl|__except|_export|_far16|_fastcall"
</FONT> <FONT color=#0000ff>"|__finally|_fortran|_import|_pascal|_stdcall|__thread|__try|asm|auto|bool"
</FONT> <FONT color=#0000ff>"|break|case|catch|cdecl|char|class|const|const_cast|continue|default|delete"
</FONT> <FONT color=#0000ff>"|do|double|dynamic_cast|else|enum|explicit|extern|false|float|for|friend|goto"
</FONT> <FONT color=#0000ff>"|if|inline|int|long|mutable|namespace|new|operator|pascal|private|protected"
</FONT> <FONT color=#0000ff>"|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_cast"
</FONT> <FONT color=#0000ff>"|struct|switch|template|this|throw|true|try|typedef|typeid|typename|union|unsigned"
</FONT> <FONT color=#0000ff>"|using|virtual|void|volatile|wchar_t|while)\\&gt;"
</FONT> ;
<B>const</B> <B>char</B>* format_string = <FONT color=#0000ff>"(?1&lt;font color=\"#008040\"&gt;$&amp;&lt;/font&gt;)"
</FONT> <FONT color=#0000ff>"(?2&lt;I&gt;&lt;font color=\"#000080\"&gt;$&amp;&lt;/font&gt;&lt;/I&gt;)"
</FONT> <FONT color=#0000ff>"(?3&lt;font color=\"#0000A0\"&gt;$&amp;&lt;/font&gt;)"
</FONT> <FONT color=#0000ff>"(?4&lt;font color=\"#0000FF\"&gt;$&amp;&lt;/font&gt;)"
</FONT> <FONT color=#0000ff>"(?5&lt;B&gt;$&amp;&lt;/B&gt;)"</FONT>;
<B>const</B> <B>char</B>* header_text = <FONT color=#0000ff>"&lt;HTML&gt;\n&lt;HEAD&gt;\n"
</FONT> <FONT color=#0000ff>"&lt;TITLE&gt;Auto-generated html formated source&lt;/TITLE&gt;\n"
</FONT> <FONT color=#0000ff>"&lt;META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=windows-1252\"&gt;\n"
</FONT> <FONT color=#0000ff>"&lt;/HEAD&gt;\n"
</FONT> <FONT color=#0000ff>"&lt;BODY LINK=\"#0000ff\" VLINK=\"#800080\" BGCOLOR=\"#ffffff\"&gt;\n"
</FONT> <FONT color=#0000ff>"&lt;P&gt; &lt;/P&gt;\n&lt;PRE&gt;"</FONT>;
<B>const</B> <B>char</B>* footer_text = <FONT color=#0000ff>"&lt;/PRE&gt;\n&lt;/BODY&gt;\n\n"</FONT>;
<HR></PRE>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

332
doc/Attic/regex_search.html Normal file
View File

@ -0,0 +1,332 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Algorithm regex_search</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<LINK href="../../../boost.css" type="text/css" rel="stylesheet"></head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td vAlign="top" width="300">
<h3><A href="../../../index.htm"><IMG height="86" alt="C++ Boost" src="../../../c++boost.gif" width="277" border="0"></A></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">Algorithm regex_search</H2>
</TD>
<td width="50">
<h3><A href="index.html"><IMG height="45" alt="Boost.Regex Index" src="uarrow.gif" width="43" border="0"></A></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<H3>Contents</H3>
<dl class="index">
<dt><A href="#synopsis">Synopsis</A> <dt><a href="#description">Description</a> <dt><A href="#examples">
Examples</A></dt></dl>
<H3><A name="synopsis"></A>Synopsis</H3>
<PRE>#include &lt;<A href="../../boost/regex.hpp">boost/regex.hpp</A>&gt; </PRE>
<P></P>
<P>The algorithm regex_search will search a range denoted by a pair of
bidirectional-iterators for a given regular expression. The algorithm uses
various heuristics to reduce the search time by only checking for a match if a
match could conceivably start at that position. The algorithm is defined as
follows:
<PRE>template &lt;class BidirectionalIterator,
class Allocator, class charT,
class traits, class Allocator2&gt;
bool regex_search(BidirectionalIterator first, BidirectionalIterator last,
<a href=match_results.html>match_results</a>&lt;BidirectionalIterator, Allocator&gt;&amp; m,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator2&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);
template &lt;class ST, class SA,
class Allocator, class charT,
class traits, class Allocator2&gt;
bool regex_search(const basic_string&lt;charT, ST, SA&gt;&amp; s,
<a href=match_results.html>match_results</a>&lt;
typename basic_string&lt;charT, ST,SA&gt;::const_iterator,
Allocator&gt;&amp; m,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator2&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);
template&lt;class charT, class Allocator, class traits,
class Allocator2&gt;
bool regex_search(const charT* str,
<a href=match_results.html>match_results</a>&lt;const charT*, Allocator&gt;&amp; m,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator2&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);
template &lt;class BidirectionalIterator, class Allocator,
class charT, class traits&gt;
bool regex_search(BidirectionalIterator first, BidirectionalIterator last,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);
template &lt;class charT, class Allocator,
class traits&gt;
bool regex_search(const charT* str,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);
template&lt;class ST, class SA,
class Allocator, class charT,
class traits&gt;
bool regex_search(const basic_string&lt;charT, ST, SA&gt;&amp; s,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);
</PRE>
<H3><A name="description"></A>Description</H3>
<PRE>template &lt;class BidirectionalIterator, class Allocator, class charT,
class traits, class Allocator2&gt;
bool regex_search(BidirectionalIterator first, BidirectionalIterator last,
<a href=match_results.html>match_results</a>&lt;BidirectionalIterator, Allocator&gt;&amp; m,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator2&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);</PRE>
<B>
<P>
Requires:</B> Type BidirectionalIterator meets the requirements of a
Bidirectional Iterator (24.1.4).</P>
<B>
<P>
Effects: </B>Determines whether there is some sub-sequence within
[first,last) that matches the regular expression <I>e</I>, parameter <I>flags</I>
is used to control how the expression is matched against the character
sequence. Returns true if such a sequence exists, false otherwise.</P><B>
<P>
Postconditions: </B>If the function returns false, then the effect on
parameter <I>m</I> is undefined, otherwise the effects on parameter <I>m</I> are
given in the table:</P>
<DIV align="center">
<CENTER>
<TABLE id="Table2" cellSpacing="1" cellPadding="7" width="624" border="1">
<TR>
<TD vAlign="top" width="50%"><B>
<P>
Element</B></P></TD>
<TD vAlign="top" width="50%"><B>
<P>
Value</B> </P></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.size()</P>
</TD>
<TD vAlign="top" width="50%">
<P>e.mark_count()</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.empty()</P>
</TD>
<TD vAlign="top" width="50%">
<P>false</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.prefix().first</P>
</TD>
<TD vAlign="top" width="50%">
<P>first</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.prefix().last</P>
</TD>
<TD vAlign="top" width="50%">
<P>m[0].first</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.prefix().matched</P>
</TD>
<TD vAlign="top" width="50%">
<P>m.prefix().first != m.prefix().second</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.suffix().first</P>
</TD>
<TD vAlign="top" width="50%">
<P>m[0].second</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.suffix().last</P>
</TD>
<TD vAlign="top" width="50%">
<P>last</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.suffix().matched</P>
</TD>
<TD vAlign="top" width="50%">
<P>m.suffix().first != m.suffix().second</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[0].first</P>
</TD>
<TD vAlign="top" width="50%">
<P>The start of the sequence of characters that matched the regular expression</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[0].second</P>
</TD>
<TD vAlign="top" width="50%">
<P>The end of the sequence of characters that matched the regular expression</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[0].matched</P>
</TD>
<TD vAlign="top" width="50%"><CODE>
<P>
true</CODE> if a full match was found, and <CODE>false</CODE> if it was a
partial match (found as a result of the <CODE>match_partial</CODE> flag being
set).</P></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[n].first</P>
</TD>
<TD vAlign="top" width="50%">
<P>For all integers n &lt; m.size(), the start of the sequence that matched
sub-expression <I>n</I>. Alternatively, if sub-expression n did not participate
in the match, then <I>last</I>.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[n].second</P>
</TD>
<TD vAlign="top" width="50%">
<P>For all integers n &lt; m.size(), the end of the sequence that matched
sub-expression <I>n</I>. Alternatively, if sub-expression n did not participate
in the match, then <I>last</I>.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[n].matched</P>
</TD>
<TD vAlign="top" width="50%">
<P>For all integers n &lt; m.size(), true if sub-expression <I>n</I> participated
in the match, false otherwise.</P>
<P></P>
</TD>
</TR>
</TD></TR></TABLE>
</CENTER>
</DIV>
<PRE>template &lt;class charT, class Allocator, class traits, class Allocator2&gt;
bool regex_search(const charT* str, <a href=match_results.html>match_results</a>&lt;const charT*, Allocator&gt;&amp; m,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator2&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>regex_search(str, str +
char_traits&lt;charT&gt;::length(str), m, e, flags)</CODE>.</P><PRE>template &lt;class ST, class SA, class Allocator, class charT,
class traits, class Allocator2&gt;
bool regex_search(const basic_string&lt;charT, ST, SA&gt;&amp; s,
<a href=match_results.html>match_results</a>&lt;typename basic_string&lt;charT, ST, SA&gt;::const_iterator, Allocator&gt;&amp; m,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator2&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>regex_search(s.begin(), s.end(), m, e,
flags)</CODE>.</P><PRE>template &lt;class iterator, class Allocator, class charT,
class traits&gt;
bool regex_search(iterator first, iterator last,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Behaves "as if" by constructing an instance of <CODE><a href="match_results.html">
match_results</a>&lt;</CODE>BidirectionalIterator<CODE>&gt; what</CODE>,
and then returning the result of <CODE>regex_search(first, last, what, e, flags)</CODE>.</P><PRE>template &lt;class charT, class Allocator, class traits&gt;
bool regex_search(const charT* str
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>regex_search(str, str +
char_traits&lt;charT&gt;::length(str), e, flags)</CODE>.</P><PRE>template &lt;class ST, class SA, class Allocator, class charT,
class traits&gt;
bool regex_search(const basic_string&lt;charT, ST, SA&gt;&amp; s,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>regex_search(s.begin(), s.end(), e,
flags)</CODE>.
<H3><A name="examples"></A>Examples</H3>
<P>The following <A href="../example/snippets/regex_search_example.cpp">example</A>,
takes the contents of a file in the form of a string, and searches for all the
C++ class declarations in the file. The code will work regardless of the way
that std::string is implemented, for example it could easily be modified to
work with the SGI rope class, which uses a non-contiguous storage strategy.</P>
<P></P>
<PRE><FONT color=#008000>#include &lt;string&gt;
#include &lt;map&gt;
#include &lt;boost/regex.hpp&gt;
</FONT><FONT color=#000080><I>
// purpose:
// takes the contents of a file in the form of a string
// and searches for all the C++ class definitions, storing
// their locations in a map of strings/int's
</I></FONT><B>typedef</B> std::map&lt;std::string, <B>int</B>, std::less&lt;std::string&gt; &gt; map_type;
boost::regex expression("^(template[[:space:]]*&lt;[^;:{]+&gt;[[:space:]]*)?(class|struct)[[:space:]]*(\\&lt;\\w+\\&gt;([[:blank:]]*\\([^)]*\\))?[[:space:]]*)*(\\&lt;\\w*\\&gt;)[[:space:]]*(&lt;[^;:{]+&gt;[[:space:]]*)?(\\{|:[^;\\{()]*\\{)");
<B>
void</B> IndexClasses(map_type&amp; m, <B>const</B> std::string&amp; file)
{
&nbsp;&nbsp; std::string::const_iterator start, end;
&nbsp;&nbsp; start = file.begin();
&nbsp;&nbsp; end = file.end();&nbsp;
&nbsp;&nbsp; &nbsp;&nbsp; boost::<a href=match_results.html>match_results</a>&lt;std::string::const_iterator&gt; what;
&nbsp;&nbsp; <B>unsigned</B> <B>int</B> flags = boost::match_default;
&nbsp;&nbsp; <B>while</B>(regex_search(start, end, what, expression, flags))&nbsp;
&nbsp;&nbsp; {
<FONT color=#000080>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <I>// what[0] contains the whole string
</I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <I>// what[5] contains the class name.
</I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <I>// what[6] contains the template specialisation if any.
</I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <I>// add class name and position to map:
</I></FONT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m[std::string(what[5].first, what[5].second) + std::string(what[6].first, what[6].second)] =&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; what[5].first - file.begin();&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#000080><I>// update search position:
</I></FONT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; start = what[0].second;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#000080><I>// update flags:
</I></FONT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; flags |= boost::match_prev_avail;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; flags |= boost::match_not_bob;&nbsp;
&nbsp;&nbsp; }
}
<HR></PRE>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

143
doc/Attic/regex_split.html Normal file
View File

@ -0,0 +1,143 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Algorithm regex_split (deprecated)</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">Algorithm regex_split (deprecated)</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<P>The algorithm regex_split has been deprecated in favour of the iterator <A href="regex_token_iterator.html">
regex_token_iterator</A> which has a more flexible and powerful interface,
as well as following the more usual standard library "pull" rather than "push"
semantics.</P>
<P>Code which uses regex_split will continue to compile, the following
documentation is taken from the previous boost.regex version:</P>
<H3><A name="regex_split"></A>Algorithm regex_split</H3>
<PRE>#include &lt;<A href="../../../boost/regex.hpp">boost/regex.hpp</A>&gt; </PRE>
<P>Algorithm regex_split performs a similar operation to the perl split operation,
and comes in three overloaded forms:
</P>
<PRE><B>template</B> &lt;<B>class</B> OutputIterator, <B>class</B> charT, <B>class</B> Traits1, <B>class</B> Alloc1, <B>class</B> Traits2, <B>class</B> Alloc2&gt;
std::size_t regex_split(OutputIterator out,&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::basic_string&lt;charT, Traits1, Alloc1&gt;&amp; s,&nbsp;
&nbsp;<B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; const</B> basic_regex&lt;charT, Traits2, Alloc2&gt;&amp; e,
&nbsp;<B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; unsigned</B> flags,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::size_t max_split);
<B>template</B> &lt;<B>class</B> OutputIterator, <B>class</B> charT, <B>class</B> Traits1, <B>class</B> Alloc1, <B>class</B> Traits2, <B>class</B> Alloc2&gt;
std::size_t regex_split(OutputIterator out,&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::basic_string&lt;charT, Traits1, Alloc1&gt;&amp; s,&nbsp;
&nbsp;<B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; const</B> basic_regex&lt;charT, Traits2, Alloc2&gt;&amp; e,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>unsigned</B> flags = match_default);
<B>template</B> &lt;<B>class</B> OutputIterator, <B>class</B> charT, <B>class</B> Traits1, <B>class</B> Alloc1&gt;
std::size_t regex_split(OutputIterator out,
std::basic_string&lt;charT, Traits1, Alloc1&gt;&amp; s);</PRE>
<P>Each version takes an output-iterator for output, and a string for input. If
the expression contains no marked sub-expressions, then the algorithm writes
one string onto the output-iterator for each section of input that does not
match the expression. If the expression does contain marked sub-expressions,
then each time a match is found, one string for each marked sub-expression will
be written to the output-iterator. No more than <I>max_split </I>strings will
be written to the output-iterator. Before returning, all the input processed
will be deleted from the string <I>s</I> (if <I>max_split </I>is not reached
then all of <I>s</I> will be deleted). Returns the number of strings written to
the output-iterator. If the parameter <I>max_split</I> is not specified then it
defaults to UINT_MAX. If no expression is specified, then it defaults to "\s+",
and splitting occurs on whitespace.
</P>
<P><A href="../example/snippets/regex_split_example_1.cpp">Example</A>: the following
function will split the input string into a series of tokens, and remove each
token from the string <I>s</I>:
</P>
<PRE><B>unsigned</B> tokenise(std::list&lt;std::string&gt;&amp; l, std::string&amp; s)
{
<B>&nbsp;&nbsp; return</B> boost::regex_split(std::back_inserter(l), s);
}</PRE>
<P><A href="../example/snippets/regex_split_example_2.cpp">Example</A>: the following
short program will extract all of the URL's from a html file, and print them
out to <I>cout</I>:
</P>
<PRE><FONT color=#008000>#include &lt;list&gt;
#include &lt;fstream&gt;
#include &lt;iostream&gt;
#include &lt;boost/regex.hpp&gt;
</FONT>
boost::regex e(<FONT color=#000080>"&lt;\\s*A\\s+[^&gt;]*href\\s*=\\s*\"([^\"]*)\""</FONT>,
boost::regbase::normal | boost::regbase::icase);
<B>void</B> load_file(std::string&amp; s, std::istream&amp; is)
{
s.erase();
<FONT color=#000080>//
// attempt to grow string buffer to match file size,
// this doesn't always work...
</FONT> s.reserve(is.rdbuf()-&amp;gtin_avail());
<B>char</B> c;
<B>while</B>(is.get(c))
{
<FONT color=#000080>// use logarithmic growth stategy, in case
// in_avail (above) returned zero:
</FONT> <B>if</B>(s.capacity() == s.size())
s.reserve(s.capacity() * 3);
s.append(1, c);
}
}
<B>int</B> main(<B>int</B> argc, <B>char</B>** argv)
{
std::string s;
std::list&lt;std::string&gt; l;
<B>for</B>(<B>int</B> i = 1; i &lt; argc; ++i)
{
std::cout &lt;&lt; <FONT color=#000080>"Findings URL's in "</FONT> &lt;&lt; argv[i] &lt;&lt; <FONT color=#000080>":"</FONT> &lt;&lt; std::endl;
s.erase();
std::ifstream is(argv[i]);
load_file(s, is);
boost::regex_split(std::back_inserter(l), s, e);
<B>while</B>(l.size())
{
s = *(l.begin());
l.pop_front();
std::cout &lt;&lt; s &lt;&lt; std::endl;
}
}
<B>return</B> 0;
}</PRE>
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -0,0 +1,47 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: class regex_traits</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">class regex_traits</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<P>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>.&nbsp;</P>
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

427
doc/Attic/sub_match.html Normal file
View File

@ -0,0 +1,427 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: sub_match</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">sub_match</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<H3>Synopsis</H3>
<P>#include &lt;<A href="../../boost/regex.hpp">boost/regex.hpp</A>&gt;
</P>
<P>Regular expressions are different from many simple pattern-matching algorithms
in that as well as finding an overall match they can also produce
sub-expression matches: each sub-expression being delimited in the pattern by a
pair of parenthesis (...). There has to be some method for reporting
sub-expression matches back to the user: this is achieved this by defining a
class <I><A href="match_results.htm">match_results</A></I> that acts as an
indexed collection of sub-expression matches, each sub-expression match being
contained in an object of type <I>sub_match</I>
.
<P>Objects of type <EM>sub_match</EM> may only obtained by subscripting an object
of type <EM><A href="match_results.html">match_results</A></EM>
.
<P>When the marked sub-expression denoted by an object of type sub_match&lt;&gt;
participated in a regular expression match then member <CODE>matched</CODE> evaluates
to true, and members <CODE>first</CODE> and <CODE>second</CODE> denote the
range of characters <CODE>[first,second)</CODE> which formed that match.
Otherwise <CODE>matched</CODE> is false, and members <CODE>first</CODE> and <CODE>second</CODE>
contained undefined values.</P>
<P>If an object of type <CODE>sub_match&lt;&gt;</CODE> represents sub-expression 0
- that is to say the whole match - then member <CODE>matched</CODE> is always
true, unless a partial match was obtained as a result of the flag <CODE>match_partial</CODE>
being passed to a regular expression algorithm, in which case member <CODE>matched</CODE>
is false, and members <CODE>first</CODE> and <CODE>second</CODE> represent the
character range that formed the partial match.</P>
<PRE>
namespace boost{
template &lt;class BidirectionalIterator&gt;
class sub_match : public std::pair&lt;BidirectionalIterator, BidirectionalIterator&gt;
{
public:
typedef typename iterator_traits&lt;BidirectionalIterator&gt;::value_type value_type;
typedef typename iterator_traits&lt;BidirectionalIterator&gt;::difference_type difference_type;
typedef BidirectionalIterator iterator;
bool matched;
difference_type length()const;
operator basic_string&lt;value_type&gt;()const;
basic_string&lt;value_type&gt; str()const;
int compare(const sub_match&amp; s)const;
int compare(const basic_string&lt;value_type&gt;&amp; s)const;
int compare(const value_type* s)const;
};
template &lt;class BidirectionalIterator&gt;
bool operator == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool operator == (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool operator != (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool operator &lt; (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool operator &gt; (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool operator &gt;= (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool operator &lt;= (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool operator == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool operator != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool operator &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool operator &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool operator &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool operator &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator == (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator != (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &lt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &gt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &gt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &lt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs);
template &lt;class BidirectionalIterator&gt;
bool operator != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs);
template &lt;class BidirectionalIterator&gt;
bool operator == (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator != (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &lt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &gt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &gt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &lt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs);
template &lt;class charT, class traits, class BidirectionalIterator&gt;
basic_ostream&lt;charT, traits&gt;&amp;
operator &lt;&lt; (basic_ostream&lt;charT, traits&gt;&amp; os,
const sub_match&lt;BidirectionalIterator&gt;&amp; m);
} // namespace boost</PRE>
<H3>Description</H3>
<H4>
sub_match members</H4>
<PRE>typedef typename std::iterator_traits&lt;iterator&gt;::value_type value_type;</PRE>
<P>The type pointed to by the iterators.</P>
<PRE>typedef typename std::iterator_traits&lt;iterator&gt;::difference_type difference_type;</PRE>
<P>A type that represents the difference between two iterators.</P>
<PRE>typedef iterator iterator_type;</PRE>
<P>The iterator type.</P>
<PRE>iterator first</PRE>
<P>An iterator denoting the position of the start of the match.</P>
<PRE>iterator second</PRE>
<P>An iterator denoting the position of the end of the match.</P>
<PRE>bool matched</PRE>
<P>A Boolean value denoting whether this sub-expression participated in the match.</P>
<PRE>static difference_type length();</PRE>
<B>
<P>
Effects: </B>returns <CODE>(matched ? 0 : distance(first, second))</CODE>.</P><PRE>operator basic_string&lt;value_type&gt;()const;</PRE>
<B>
<P>
Effects: </B>returns <CODE>(matched ? basic_string&lt;value_type&gt;(first,
second) : basic_string&lt;value_type&gt;()).</P></CODE><PRE>basic_string&lt;value_type&gt; str()const;</PRE>
<B>
<P>
Effects: </B>returns <CODE>(matched ? basic_string&lt;value_type&gt;(first,
second) : basic_string&lt;value_type&gt;())</CODE>.</P><PRE>int compare(const sub_match&amp; s)const;</PRE>
<B>
<P>
Effects: </B>returns <CODE>str().compare(s.str())</CODE>.</P><PRE>int compare(const basic_string&lt;value_type&gt;&amp; s)const;</PRE>
<B>
<P>
Effects: </B>returns <CODE>str().compare(s)</CODE>.</P><PRE>int compare(const value_type* s)const;</PRE>
<B>
<P>
Effects: </B>returns <CODE>str().compare(s)</CODE>.</P>
<H4>
sub_match non-member operators</H4>
<PRE>template &lt;class BidirectionalIterator&gt;
bool operator == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);</PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs.compare(rhs) == 0</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);</PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs.compare(rhs) != 0</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);</PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs.compare(rhs) &lt; 0</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);</PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs.compare(rhs) &lt;= 0</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);</PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs.compare(rhs) &gt;= 0</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);</PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs.compare(rhs) &gt; 0</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator == (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs == rhs.str()</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator != (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs != rhs.str()</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &lt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs &lt; rhs.str()</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &gt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs &gt; rhs.str()</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &gt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs &gt;= rhs.str()</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &lt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs &lt;= rhs.str()</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs.str() == rhs</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs.str() != rhs</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs.str() &lt; rhs</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs.str() &gt; rhs</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs.str() &gt;= rhs</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs.str() &lt;= rhs</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator == (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs == rhs.str()</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator != (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs != rhs.str()</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &lt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs &lt; rhs.str()</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &gt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs &gt; rhs.str()</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &gt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs &gt;= rhs.str()</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &lt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs &lt;= rhs.str()</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs.str() == rhs</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs.str() != rhs</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs.str() &lt; rhs</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs.str() &gt; rhs</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs.str() &gt;= rhs</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs.str() &lt;= rhs</CODE>.</P><PRE>template &lt;class charT, class traits, class BidirectionalIterator&gt;
basic_ostream&lt;charT, traits&gt;&amp;
operator &lt;&lt; (basic_ostream&lt;charT, traits&gt;&amp; os
const sub_match&lt;BidirectionalIterator&gt;&amp; m);</PRE>
<B>
<P>
Effects: </B>returns <CODE>(os &lt;&lt; m.str())</CODE>.
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

783
doc/Attic/syntax.html Normal file
View File

@ -0,0 +1,783 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Regular Expression Syntax</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">Regular Expression Syntax</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<P>This section covers the regular expression syntax used by this library, this is
a programmers guide, the actual syntax presented to your program's users will
depend upon the flags used during expression compilation.
</P>
<H3>Literals
</H3>
<P>All characters are literals except: ".", "|", "*", "?", "+", "(", ")", "{",
"}", "[", "]", "^", "$" and "\". These characters are literals when preceded by
a "\". A literal is a character that matches itself, or matches the result of
traits_type::translate(), where traits_type is the traits template parameter to
class reg_expression.</P>
<H3>Wildcard
</H3>
<P>The dot character "." matches any single character except : when <I>match_not_dot_null</I>
is passed to the matching algorithms, the dot does not match a null character;
when <I>match_not_dot_newline</I> is passed to the matching algorithms, then
the dot does not match a newline character.
</P>
<H3>Repeats
</H3>
<P>A repeat is an expression that is repeated an arbitrary number of times. An
expression followed by "*" can be repeated any number of times including zero.
An expression followed by "+" can be repeated any number of times, but at least
once, if the expression is compiled with the flag regex_constants::bk_plus_qm
then "+" is an ordinary character and "\+" represents a repeat of once or more.
An expression followed by "?" may be repeated zero or one times only, if the
expression is compiled with the flag regex_constants::bk_plus_qm then "?" is an
ordinary character and "\?" represents the repeat zero or once operator. When
it is necessary to specify the minimum and maximum number of repeats
explicitly, the bounds operator "{}" may be used, thus "a{2}" is the letter "a"
repeated exactly twice, "a{2,4}" represents the letter "a" repeated between 2
and 4 times, and "a{2,}" represents the letter "a" repeated at least twice with
no upper limit. Note that there must be no white-space inside the {}, and there
is no upper limit on the values of the lower and upper bounds. When the
expression is compiled with the flag regex_constants::bk_braces then "{" and
"}" are ordinary characters and "\{" and "\}" are used to delimit bounds
instead. All repeat expressions refer to the shortest possible previous
sub-expression: a single character; a character set, or a sub-expression
grouped with "()" for example.
</P>
<P>Examples:
</P>
<P>"ba*" will match all of "b", "ba", "baaa" etc.
</P>
<P>"ba+" will match "ba" or "baaaa" for example but not "b".
</P>
<P>"ba?" will match "b" or "ba".
</P>
<P>"ba{2,4}" will match "baa", "baaa" and "baaaa".
</P>
<H3>Non-greedy repeats
</H3>
<P>Whenever the "extended" regular expression syntax is in use (the default) then
non-greedy repeats are possible by appending a '?' after the repeat; a
non-greedy repeat is one which will match the <I>shortest</I> possible string.
</P>
<P>For example to match html tag pairs one could use something like:
</P>
<P>"&lt;\s*tagname[^&gt;]*&gt;(.*?)&lt;\s*/tagname\s*&gt;"
</P>
<P>In this case $1 will contain the text between the tag pairs, and will be the
shortest possible matching string.&nbsp;
</P>
<H3>Parenthesis
</H3>
<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="template_class_ref.htm#query_match">
regex_match</A> and <A href="template_class_ref.htm#reg_search">regex_search</A>
each take an instance of <A href="template_class_ref.htm#reg_match">match_results</A>
that reports what caused the match, on exit from these functions the <A href="template_class_ref.htm#reg_match">
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>
<P>Sometimes you need to group sub-expressions with parenthesis, but don't want
the parenthesis to spit out another marked sub-expression, in this case a
non-marking parenthesis (?:expression) can be used. For example the following
expression creates no sub-expressions:
</P>
<P>"(?:abc)*"</P>
<H3>Forward Lookahead Asserts&nbsp;
</H3>
<P>There are two forms of these; one for positive forward lookahead asserts, and
one for negative lookahead asserts:</P>
<P>"(?=abc)" matches zero characters only if they are followed by the expression
"abc".</P>
<P>"(?!abc)" matches zero characters only if they are not followed by the
expression "abc".</P>
<H3>Independent sub-expressions</H3>
<P>"(?&gt;expression)" matches "expression" as an independent atom (the algorithm
will not backtrack into it if a failure occures later in the expression).</P>
<H3>Alternatives
</H3>
<P>Alternatives occur when the expression can match either one sub-expression or
another, each alternative is separated by a "|", or a "\|" if the flag
regex_constants::bk_vbar is set, or by a newline character if the flag
regex_constants::newline_alt is set. Each alternative is the largest possible
previous sub-expression; this is the opposite behaviour from repetition
operators.
</P>
<P>Examples:
</P>
<P>"a(b|c)" could match "ab" or "ac".
</P>
<P>"abc|def" could match "abc" or "def".
</P>
<H3>Sets
</H3>
<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
elements that follow.
</P>
<P>Examples:
</P>
<P>Character literals:
</P>
<P>"[abc]" will match either of "a", "b", or "c".
</P>
<P>"[^abc] will match any character other than "a", "b", or "c".
</P>
<P>Character ranges:
</P>
<P>"[a-z]" will match any character in the range "a" to "z".
</P>
<P>"[^A-Z]" will match any character other than those in the range "A" to "Z".
</P>
<P>Note that character ranges are highly locale dependent if the flag
regex_constants::collate is set: they match any character that collates between
the endpoints of the range, ranges will only behave according to ASCII rules
when the default "C" locale is in effect. For example if the library is
compiled with the Win32 localization model, then [a-z] will match the ASCII
characters a-z, and also 'A', 'B' etc, but not 'Z' which collates just after
'z'. This locale specific behaviour is disabled by default (in perl mode), and
forces ranges to collate according to ASCII character code.
</P>
<P>Character classes are denoted using the syntax "[:classname:]" within a set
declaration, for example "[[:space:]]" is the set of all whitespace characters.
Character classes are only available if the flag regex_constants::char_classes
is set. The available character classes are:
<BR>
&nbsp;
</P>
<P>
<TABLE id="Table2" cellSpacing="0" cellPadding="7" width="100%" border="0">
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="50%">alnum</TD>
<TD vAlign="top" width="50%">Any alpha numeric character.</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">alpha</TD>
<TD vAlign="top" width="50%">Any alphabetical character a-z and A-Z. Other
characters may also be included depending upon the locale.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">blank</TD>
<TD vAlign="top" width="50%">Any blank character, either a space or a tab.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">cntrl</TD>
<TD vAlign="top" width="50%">Any control character.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">digit</TD>
<TD vAlign="top" width="50%">Any digit 0-9.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">graph</TD>
<TD vAlign="top" width="50%">Any graphical character.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">lower</TD>
<TD vAlign="top" width="50%">Any lower case character a-z. Other characters may
also be included depending upon the locale.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">print</TD>
<TD vAlign="top" width="50%">Any printable character.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">punct</TD>
<TD vAlign="top" width="50%">Any punctuation character.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">space</TD>
<TD vAlign="top" width="50%">Any whitespace character.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">upper</TD>
<TD vAlign="top" width="50%">Any upper case character A-Z. Other characters may
also be included depending upon the locale.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">xdigit</TD>
<TD vAlign="top" width="50%">Any hexadecimal digit character, 0-9, a-f and A-F.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">word</TD>
<TD vAlign="top" width="50%">Any word character - all alphanumeric characters plus
the underscore.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">unicode</TD>
<TD vAlign="top" width="50%">Any character whose code is greater than 255, this
applies to the wide character traits classes only.</TD>
<TD>&nbsp;</TD>
</TR>
</TABLE>
</P>
<P>There are some shortcuts that can be used in place of the character classes,
provided the flag regex_constants::escape_in_lists is set then you can use:
</P>
<P>\w in place of [:word:]
</P>
<P>\s in place of [:space:]
</P>
<P>\d in place of [:digit:]
</P>
<P>\l in place of [:lower:]
</P>
<P>\u in place of [:upper:]&nbsp;
</P>
<P>Collating elements take the general form [.tagname.] inside a set declaration,
where <I>tagname</I> is either a single character, or a name of a collating
element, for example [[.a.]] is equivalent to [a], and [[.comma.]] is
equivalent to [,]. The library supports all the standard POSIX collating
element names, and in addition the following digraphs: "ae", "ch", "ll", "ss",
"nj", "dz", "lj", each in lower, upper and title case variations.
Multi-character collating elements can result in the set matching more than one
character, for example [[.ae.]] would match two characters, but note that
[^[.ae.]] would only match one character.&nbsp;
</P>
<P>
Equivalence classes take the general form[=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
a set of characters that collate the same, a primary equivalence class is a set
of characters whose primary sort key are all the same (for example strings are
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
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
equivalence classes are probably best considered broken under any operating
system other than Win32.&nbsp;
</P>
<P>To include a literal "-" in a set declaration then: make it the first character
after the opening "[" or "[^", the endpoint of a range, a collating element, or
if the flag regex_constants::escape_in_lists is set then precede with an escape
character as in "[\-]". To include a literal "[" or "]" or "^" in a set then
make them the endpoint of a range, a collating element, or precede with an
escape character if the flag regex_constants::escape_in_lists is set.
</P>
<H3>Line anchors
</H3>
<P>An anchor is something that matches the null string at the start or end of a
line: "^" matches the null string at the start of a line, "$" matches the null
string at the end of a line.
</P>
<H3>Back references
</H3>
<P>A back reference is a reference to a previous sub-expression that has already
been matched, the reference is to what the sub-expression matched, not to the
expression itself. A back reference consists of the escape character "\"
followed by a digit "1" to "9", "\1" refers to the first sub-expression, "\2"
to the second etc. For example the expression "(.*)\1" matches any string that
is repeated about its mid-point for example "abcabc" or "xyzxyz". A back
reference to a sub-expression that did not participate in any match, matches
the null string: NB this is different to some other regular expression
matchers. Back references are only available if the expression is compiled with
the flag regex_constants::bk_refs set.
</P>
<H3>Characters by code
</H3>
<P>This is an extension to the algorithm that is not available in other libraries,
it consists of the escape character followed by the digit "0" followed by the
octal character code. For example "\023" represents the character whose octal
code is 23. Where ambiguity could occur use parentheses to break the expression
up: "\0103" represents the character whose code is 103, "(\010)3 represents the
character 10 followed by "3". To match characters by their hexadecimal code,
use \x followed by a string of hexadecimal digits, optionally enclosed inside
{}, for example \xf0 or \x{aff}, notice the latter example is a Unicode
character.</P>
<H3>Word operators
</H3>
<P>The following operators are provided for compatibility with the GNU regular
expression library.
</P>
<P>"\w" matches any single character that is a member of the "word" character
class, this is identical to the expression "[[:word:]]".
</P>
<P>"\W" matches any single character that is not a member of the "word" character
class, this is identical to the expression "[^[:word:]]".
</P>
<P>"\&lt;" matches the null string at the start of a word.
</P>
<P>"\&gt;" matches the null string at the end of the word.
</P>
<P>"\b" matches the null string at either the start or the end of a word.
</P>
<P>"\B" matches a null string within a word.
</P>
<P>The start of the sequence passed to the matching algorithms is considered to be
a potential start of a word unless the flag match_not_bow is set. The end of
the sequence passed to the matching algorithms is considered to be a potential
end of a word unless the flag match_not_eow is set.
</P>
<H3>Buffer operators
</H3>
<P>The following operators are provide for compatibility with the GNU regular
expression library, and Perl regular expressions:
</P>
<P>"\`" matches the start of a buffer.
</P>
<P>"\A" matches the start of the buffer.
</P>
<P>"\'" matches the end of a buffer.
</P>
<P>"\z" matches the end of a buffer.
</P>
<P>"\Z" matches the end of a buffer, or possibly one or more new line characters
followed by the end of the buffer.
</P>
<P>A buffer is considered to consist of the whole sequence passed to the matching
algorithms, unless the flags match_not_bob or match_not_eob are set.
</P>
<H3>Escape operator
</H3>
<P>The escape character "\" has several meanings.
</P>
<P>Inside a set declaration the escape character is a normal character unless the
flag regex_constants::escape_in_lists is set in which case whatever follows the
escape is a literal character regardless of its normal meaning.
</P>
<P>The escape operator may introduce an operator for example: back references, or
a word operator.
</P>
<P>The escape operator may make the following character normal, for example "\*"
represents a literal "*" rather than the repeat operator.
</P>
<H4>Single character escape sequences
</H4>
<P>The following escape sequences are aliases for single characters:
<BR>
&nbsp;
</P>
<P>
<TABLE id="Table3" cellSpacing="0" cellPadding="7" width="100%" border="0">
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="33%">Escape sequence
</TD>
<TD vAlign="top" width="33%">Character code
</TD>
<TD vAlign="top" width="33%">Meaning
</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="33%">\a
</TD>
<TD vAlign="top" width="33%">0x07
</TD>
<TD vAlign="top" width="33%">Bell character.
</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="33%">\f
</TD>
<TD vAlign="top" width="33%">0x0C
</TD>
<TD vAlign="top" width="33%">Form feed.
</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="33%">\n
</TD>
<TD vAlign="top" width="33%">0x0A
</TD>
<TD vAlign="top" width="33%">Newline character.
</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="33%">\r
</TD>
<TD vAlign="top" width="33%">0x0D
</TD>
<TD vAlign="top" width="33%">Carriage return.
</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="33%">\t
</TD>
<TD vAlign="top" width="33%">0x09
</TD>
<TD vAlign="top" width="33%">Tab character.
</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="33%">\v
</TD>
<TD vAlign="top" width="33%">0x0B
</TD>
<TD vAlign="top" width="33%">Vertical tab.
</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="33%">\e
</TD>
<TD vAlign="top" width="33%">0x1B
</TD>
<TD vAlign="top" width="33%">ASCII Escape character.
</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="33%">\0dd
</TD>
<TD vAlign="top" width="33%">0dd
</TD>
<TD vAlign="top" width="33%">An octal character code, where <I>dd</I> is one or
more octal digits.
</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="33%">\xXX
</TD>
<TD vAlign="top" width="33%">0xXX
</TD>
<TD vAlign="top" width="33%">A hexadecimal character code, where XX is one or more
hexadecimal digits.
</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="33%">\x{XX}
</TD>
<TD vAlign="top" width="33%">0xXX
</TD>
<TD vAlign="top" width="33%">A hexadecimal character code, where XX is one or more
hexadecimal digits, optionally a unicode character.
</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="33%">\cZ
</TD>
<TD vAlign="top" width="33%">z-@
</TD>
<TD vAlign="top" width="33%">An ASCII escape sequence control-Z, where Z is any
ASCII character greater than or equal to the character code for '@'.
</TD>
<TD>&nbsp;</TD>
</TR>
</TABLE>
</P>
<H4>Miscellaneous escape sequences:
</H4>
<P>The following are provided mostly for perl compatibility, but note that there
are some differences in the meanings of \l \L \u and \U:
<BR>
&nbsp;
</P>
<P>
<TABLE id="Table4" cellSpacing="0" cellPadding="6" width="100%" border="0">
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">\w
</TD>
<TD vAlign="top" width="45%">Equivalent to [[:word:]].
</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">\W
</TD>
<TD vAlign="top" width="45%">Equivalent to [^[:word:]].
</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">\s
</TD>
<TD vAlign="top" width="45%">Equivalent to [[:space:]].
</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">\S
</TD>
<TD vAlign="top" width="45%">Equivalent to [^[:space:]].
</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">\d
</TD>
<TD vAlign="top" width="45%">Equivalent to [[:digit:]].
</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">\D
</TD>
<TD vAlign="top" width="45%">Equivalent to [^[:digit:]].
</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">\l
</TD>
<TD vAlign="top" width="45%">Equivalent to [[:lower:]].
</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">\L
</TD>
<TD vAlign="top" width="45%">Equivalent to [^[:lower:]].
</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">\u
</TD>
<TD vAlign="top" width="45%">Equivalent to [[:upper:]].
</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">\U
</TD>
<TD vAlign="top" width="45%">Equivalent to [^[:upper:]].
</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">\C
</TD>
<TD vAlign="top" width="45%">Any single character, equivalent to '.'.
</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">\X
</TD>
<TD vAlign="top" width="45%">Match any Unicode combining character sequence, for
example "a\x 0301" (a letter a with an acute).
</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">\Q
</TD>
<TD vAlign="top" width="45%">The begin quote operator, everything that follows is
treated as a literal character until a \E end quote operator is found.
</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">\E
</TD>
<TD vAlign="top" width="45%">The end quote operator, terminates a sequence begun
with \Q.
</TD>
<TD width="5%">&nbsp;</TD>
</TR>
</TABLE>
</P>
<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 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:
<P></P>
<P>
<DIV align="center">
<P></P>
<P align="center">
<CENTER>
<TABLE id="Table5" cellSpacing="1" cellPadding="7" width="624" border="1">
<TBODY>
<TR>
<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%"><CODE>
<P>
a|ab</CODE>
</P>
</TD>
<TD vAlign="top" width="25%"><CODE>
<P>
xaby</CODE>
</P>
</TD>
<TD vAlign="top" width="25%"><CODE>
<P>
"ab"</CODE></P></TD>
<TD vAlign="top" width="25%"><CODE>
<P>
"a"</CODE></P></TD>
</TR>
<TR>
<TD vAlign="top" width="25%"><CODE>
<P>
.*([[:alnum:]]+).*</CODE></P></TD>
<TD vAlign="top" width="25%"><CODE>
<P>
" 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%"><CODE>
<P>
.*(a|xayy)</CODE></P></TD>
<TD vAlign="top" width="25%"><CODE>
<P>
zzxayyzz</CODE></P></TD>
<TD vAlign="top" width="25%"><CODE>
<P>
"zzxayy"</CODE></P></TD>
<TD vAlign="top" width="25%"><CODE>
<P>"zzxa"</P>
<P></P>
</CODE>
</TD>
</TR>
</TBODY></CODE></TD></TR></TABLE></CENTER>
<P></P>
</DIV>
<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.
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -0,0 +1,334 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: syntax_option_type</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">syntax_option_type</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<H3>Synopsis</H3>
<P>Type syntax_option type is an implementation defined bitmask type that controls
how a regular expression string is to be interpreted.&nbsp; 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;
// these flags are standardized:
static const syntax_option_type normal;
static const syntax_option_type icase;
static const syntax_option_type nosubs;
static const syntax_option_type optimize;
static const syntax_option_type collate;
static const syntax_option_type ECMAScript = normal;
static const syntax_option_type JavaScript = normal;
static const syntax_option_type JScript = normal;
static const syntax_option_type basic;
static const syntax_option_type extended;
static const syntax_option_type awk;
static const syntax_option_type grep;
static const syntax_option_type egrep;
static const syntax_option_type sed = basic;
static const syntax_option_type perl;<BR>// these are boost.regex specific:<BR>static const syntax_option_type escape_in_lists;<BR>static const syntax_option_type char_classes;<BR>static const syntax_option_type intervals;<BR>static const syntax_option_type limited_ops;<BR>static const syntax_option_type newline_alt;<BR>static const syntax_option_type bk_plus_qm;<BR>static const syntax_option_type bk_braces;<BR>static const syntax_option_type bk_parens;<BR>static const syntax_option_type bk_refs;<BR>static const syntax_option_type bk_vbar;<BR>static const syntax_option_type use_except;<BR>static const syntax_option_type failbit;<BR>static const syntax_option_type literal;<BR>static const syntax_option_type nocollate;<BR>static const syntax_option_type perlex;<BR>static const syntax_option_type emacs;<BR>
} // namespace regex_constants
} // namespace std</PRE>
<H3>Description</H3>
<P>The type <CODE>syntax_option_type</CODE> is an implementation defined 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
or perl</CODE> set.</P>
<P>Note that for convenience all the constants listed here are duplicated within
the scope of class template basic_regex, so you can use any of:</P>
<PRE>boost::regex_constants::constant_name</PRE>
<P>or</P>
<PRE>boost::regex::constant_name</PRE>
<P>or</P>
<PRE>boost::wregex::constant_name</PRE>
<P>in an interchangeable manner.</P>
<P>
<TABLE id="Table2" height="1274" cellSpacing="1" cellPadding="7" width="100%" border="0">
<TR>
<TD vAlign="top" width="316">
<P>Element</P>
</TD>
<TD vAlign="top" width="50%">
<P>Effect if set</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="316">
<P>normal</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that the grammar recognized by the regular expression engine uses its
normal semantics: that is the same as that given in the ECMA-262, ECMAScript
Language Specification, Chapter 15 part 10, RegExp (Regular Expression) Objects
(FWD.1).</P>
<P>boost.regex also recognises most perl-compatible extensions in this mode.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="316">
<P>icase</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that matching of regular expressions against a character container
sequence shall be performed without regard to case.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="316">
<P>nosubs</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that when a regular expression is matched against a character
container sequence, then no sub-expression matches are to be stored in the
supplied match_results structure.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="316">
<P>optimize</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that the regular expression engine should pay more attention to the
speed with which regular expressions are matched, and less to the speed with
which regular expression objects are constructed. Otherwise it has no
detectable effect on the program output.&nbsp; This currently has no effect for
boost.regex.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="316">
<P>collate</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that character ranges of the form "[a-b]" should be locale sensitive.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="316">
<P>ECMAScript</P>
</TD>
<TD vAlign="top" width="50%">
<P>The same as normal.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="316">
<P>JavaScript</P>
</TD>
<TD vAlign="top" width="50%">
<P>The same as normal.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="316">
<P>JScript</P>
</TD>
<TD vAlign="top" width="50%">
<P>The same as normal.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="316">
<P>basic</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that the grammar recognized by the regular expression engine is the
same as that used by POSIX basic regular expressions in IEEE Std 1003.1-2001,
Portable Operating System Interface (POSIX ), Base Definitions and Headers,
Section 9, Regular Expressions (FWD.1).
</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="316">
<P>extended</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that the grammar recognized by the regular expression engine is the
same as that used by POSIX extended regular expressions in IEEE Std
1003.1-2001, Portable Operating System Interface (POSIX ), Base Definitions and
Headers, Section 9, Regular Expressions (FWD.1).</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="316">
<P>awk</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that the grammar recognized by the regular expression engine is the
same as that used by POSIX utility awk in IEEE Std 1003.1-2001, Portable
Operating System Interface (POSIX ), Shells and Utilities, Section 4, awk
(FWD.1).</P>
<P>That is to say: the same as POSIX extended syntax, but with escape sequences in
character classes permitted.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="316">
<P>grep</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that the grammar recognized by the regular expression engine is the
same as that used by POSIX utility grep in IEEE Std 1003.1-2001, Portable
Operating System Interface (POSIX ), Shells and Utilities, Section 4,
Utilities, grep (FWD.1).</P>
<P>That is to say, the same as POSIX basic syntax, but with the newline character
acting as an alternation character in addition to "|".</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="316">
<P>egrep</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that the grammar recognized by the regular expression engine is the
same as that used by POSIX utility grep when given the -E option in IEEE Std
1003.1-2001, Portable Operating System Interface (POSIX ), Shells and
Utilities, Section 4, Utilities, grep (FWD.1).</P>
<P>That is to say, the same as POSIX extended syntax, but with the newline
character acting as an alternation character in addition to "|".</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="316">
<P>sed</P>
</TD>
<TD vAlign="top" width="50%">
<P>The same as basic.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="316">
<P>perl</P>
</TD>
<TD vAlign="top" width="50%">
<P>The same as normal.</P>
</TD>
</TR>
</TABLE>
</P>
<P>
<P>The following constants are specific to this particular regular expression
implementation and do not appear in the <A href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1429.htm">
regular expression standardization proposal</A>:</P>
<P>
<TABLE id="Table3" cellSpacing="0" cellPadding="7" width="100%" border="0">
<TR>
<TD vAlign="top" width="45%">regbase::escape_in_lists</TD>
<TD vAlign="top" width="45%">Allows the use of the escape "\" character in sets of
characters, for example [\]] represents the set of characters containing only
"]". If this flag is not set then "\" is an ordinary character inside sets.</TD>
</TR>
<TR>
<TD vAlign="top" width="45%">regbase::char_classes</TD>
<TD vAlign="top" width="45%">When this bit is set, character classes [:classname:]
are allowed inside character set declarations, for example "[[:word:]]"
represents the set of all characters that belong to the character class "word".</TD>
</TR>
<TR>
<TD vAlign="top" width="45%">regbase:: intervals</TD>
<TD vAlign="top" width="45%">When this bit is set, repetition intervals are
allowed, for example "a{2,4}" represents a repeat of between 2 and 4 letter
a's.</TD>
</TR>
<TR>
<TD vAlign="top" width="45%">regbase:: limited_ops</TD>
<TD vAlign="top" width="45%">When this bit is set all of "+", "?" and "|" are
ordinary characters in all situations.</TD>
</TR>
<TR>
<TD vAlign="top" width="45%">regbase:: newline_alt</TD>
<TD vAlign="top" width="45%">When this bit is set, then the newline character "\n"
has the same effect as the alternation operator "|".</TD>
</TR>
<TR>
<TD vAlign="top" width="45%">regbase:: bk_plus_qm</TD>
<TD vAlign="top" width="45%">When this bit is set then "\+" represents the one or
more repetition operator and "\?" represents the zero or one repetition
operator. When this bit is not set then "+" and "?" are used instead.</TD>
</TR>
<TR>
<TD vAlign="top" width="45%">regbase:: bk_braces</TD>
<TD vAlign="top" width="45%">When this bit is set then "\{" and "\}" are used for
bounded repetitions and "{" and "}" are normal characters. This is the opposite
of default behavior.</TD>
</TR>
<TR>
<TD vAlign="top" width="45%">regbase:: bk_parens</TD>
<TD vAlign="top" width="45%">When this bit is set then "\(" and "\)" are used to
group sub-expressions and "(" and ")" are ordinary characters, this is the
opposite of default behaviour.</TD>
</TR>
<TR>
<TD vAlign="top" width="45%">regbase:: bk_refs</TD>
<TD vAlign="top" width="45%">When this bit is set then back references are
allowed.</TD>
</TR>
<TR>
<TD vAlign="top" width="45%">regbase:: bk_vbar</TD>
<TD vAlign="top" width="45%">When this bit is set then "\|" represents the
alternation operator and "|" is an ordinary character. This is the opposite of
default behaviour.</TD>
</TR>
<TR>
<TD vAlign="top" width="45%">regbase:: use_except</TD>
<TD vAlign="top" width="45%">When this bit is set then a <A href="#bad_expression">bad_expression</A>
exception will be thrown on error.&nbsp; Use of this flag is deprecated -
reg_expression will always throw on error.</TD>
</TR>
<TR>
<TD vAlign="top" width="45%">regbase:: failbit</TD>
<TD vAlign="top" width="45%">This bit is set on error, if regbase::use_except is
not set, then this bit should be checked to see if a regular expression is
valid before usage.</TD>
</TR>
<TR>
<TD vAlign="top" width="45%">regbase::literal</TD>
<TD vAlign="top" width="45%">All characters in the string are treated as literals,
there are no special characters or escape sequences.</TD>
</TR>
<TR>
<TD vAlign="top" width="45%" height="24">regbase::emacs</TD>
<TD vAlign="top" width="45%" height="24">Provides compatability with the emacs
editor, eqivalent to: bk_braces | bk_parens | bk_refs | bk_vbar.</TD>
</TR>
</TABLE>
</P>
<P>
<HR>
</P>
<P>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></P>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

View File

@ -0,0 +1,66 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Thread Safety</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">Thread Safety</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<P>Class basic_regex&lt;&gt; and its typedefs regex and wregex are thread safe, in
that compiled regular expressions can safely be shared between threads. The
matching algorithms regex_match, regex_search, regex_grep, regex_format and
regex_merge are all re-entrant and thread safe. Class match_results is now
thread safe, in that the results of a match can be safely copied from one
thread to another (for example one thread may find matches and push
match_results instances onto a queue, while another thread pops them off the
other end), otherwise use a separate instance of match_results per thread.
</P>
<P>The POSIX API functions are all re-entrant and thread safe, regular expressions
compiled with <I>regcomp</I> can also be shared between threads.
</P>
<P>The class RegEx is only thread safe if each thread gets its own RegEx instance
(apartment threading) - this is a consequence of RegEx handling both compiling
and matching regular expressions.
</P>
<P>Finally note that changing the global locale invalidates all compiled regular
expressions, therefore calling <I>set_locale</I> from one thread while another
uses regular expressions <I>will</I> produce unpredictable results.
</P>
<P>
There is also a requirement that there is only one thread executing prior to
the start of main().
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

BIN
doc/Attic/uarrow.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

77
doc/bad_expression.html Normal file
View File

@ -0,0 +1,77 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: bad_expression</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">class bad_expression</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<H3>Synopsis</H3>
<P>#include &lt;<A href="../../boost/regex/pattern_except.hpp">boost/pat_except.hpp</A>&gt;
</P>
<P>The class <CODE>bad_expression</CODE> defines the type of objects thrown as
exceptions to report errors during the conversion from a string representing a
regular expression to a finite state machine.&nbsp;&nbsp;</P>
<PRE><B>namespace</B> boost{
<B>class</B> bad_pattern : <B>public</B> std::runtime_error
{
<B>public</B>:
&nbsp;&nbsp; <B>explicit</B> bad_pattern(<B>const</B> std::string&amp; s) : std::runtime_error(s){};
};
<B>class</B> bad_expression : <B>public</B> bad_pattern
{
<B>public</B>:
&nbsp;&nbsp; bad_expression(<B>const</B> std::string&amp; s) : bad_pattern(s) {}
};
} // namespace boost</PRE>
<H3>Description</H3>
<PRE>bad_expression(const string&amp; what_arg); </PRE>
<P><B>Effects:</B> Constructs an object of class <CODE>bad_expression</CODE>.</P>
<B>
<P>
Postcondition:</B> <CODE>strcmp(what(), what_arg.c_str()) == 0</CODE>.
<P>Footnotes: the class <I>bad_pattern </I>forms the base class for all
pattern-matching exceptions, of which <I>bad_expression</I> is one. The choice
of <I>std::runtime_error </I>as the base class for <I>bad_pattern</I>
is moot, depending upon how the library is used exceptions may be either logic
errors (programmer supplied expressions) or run time errors (user supplied
expressions).
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

944
doc/basic_regex.html Normal file
View File

@ -0,0 +1,944 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: basic_regex</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">basic_regex</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<H3>Synopsis</H3>
<PRE>#include &lt;<A href="../../boost/regex.hpp">boost/regex.hpp</A>&gt; </PRE>
<P>The template class <EM>basic_regex </EM>encapsulates regular expression parsing
and compilation. The class takes three template parameters:
</P>
<P><B><I>charT</I></B>: determines the character type, i.e. either char or
wchar_t.
</P>
<P><B><I>traits</I></B>: determines the behaviour of the character type, for
example which character class names are recognized. A default traits class is
provided: <A href="regex_traits.html">regex_traits&lt;charT&gt;</A>.
</P>
<P><B><I>Allocator</I></B>: the allocator class used to allocate memory by the
class.
</P>
<P>For ease of use there are two typedefs that define the two standard <I>basic_regex </I>
instances, unless you want to use custom traits classes or allocators, you
won't need to use anything other than these:
</P>
<PRE><B>namespace</B> boost{
<B>template</B> &lt;<B>class</B> charT, <B>class</B> traits = regex_traits&lt;charT&gt;, <B>class</B> Allocator = std::allocator&lt;charT&gt;&nbsp; &gt;
<B>class</B> reg_expression;
<B>typedef</B> reg_expression&lt;<B>char</B>&gt; regex;
<B>typedef</B> reg_expression&lt;<B>wchar_t&gt; </B>wregex;
}</PRE>
<P>The definition of <I>reg_expression</I> follows: it is based very closely on
class basic_string, and fulfils the requirements for a constant-container of <I>charT</I>.
</P>
<PRE>namespace boost{
template &lt;class charT,
class traits = regex_traits&lt;charT&gt;,
class Allocator = allocator&lt;charT&gt; &gt;
class basic_regex
{
public:
// types:
typedef charT value_type;
typedef implementation defined const_iterator;
typedef const_iterator iterator;
typedef typename Allocator::reference reference;
typedef typename Allocator::const_reference const_reference;
typedef typename Allocator::difference_type difference_type;
typedef typename Allocator::size_type size_type;
typedef Allocator allocator_type;
typedef regex_constants::syntax_option_type flag_type;
typedef typename traits::locale_type locale_type;
// constants:
static const regex_constants::syntax_option_type normal = regex_constants::normal;
static const regex_constants::syntax_option_type icase = regex_constants::icase;
static const regex_constants::syntax_option_type nosubs = regex_constants::nosubs;
static const regex_constants::syntax_option_type optimize = regex_constants::optimize;
static const regex_constants::syntax_option_type collate = regex_constants::collate;
static const regex_constants::syntax_option_type ECMAScript = normal;
static const regex_constants::syntax_option_type JavaScript = normal;
static const regex_constants::syntax_option_type JScript = normal;
// these flags are optional, if the functionality is supported
// then the flags shall take these names.
static const regex_constants::syntax_option_type basic = regex_constants::basic;
static const regex_constants::syntax_option_type extended = regex_constants::extended;
static const regex_constants::syntax_option_type awk = regex_constants::awk;
static const regex_constants::syntax_option_type grep = regex_constants::grep;
static const regex_constants::syntax_option_type egrep = regex_constants::egrep;
static const regex_constants::syntax_option_type sed = basic = regex_constants::sed;
static const regex_constants::syntax_option_type perl = regex_constants::perl;
// construct/copy/destroy:
explicit basic_regex(const Allocator&amp; a = Allocator());
explicit basic_regex(const charT* p, flag_type f = regex_constants::normal,
const Allocator&amp; a = Allocator());
basic_regex(const charT* p1, const charT* p2, flag_type f = regex_constants::normal,
const Allocator&amp; a = Allocator());
basic_regex(const charT* p, size_type len, flag_type f,
const Allocator&amp; a = Allocator());
basic_regex(const basic_regex&amp;);
template &lt;class ST, class SA&gt;
explicit basic_regex(const basic_string&lt;charT, ST, SA&gt;&amp; p,
flag_type f = regex_constants::normal,
const Allocator&amp; a = Allocator());
template &lt;class InputIterator&gt;
basic_regex(InputIterator first, inputIterator last,
flag_type f = regex_constants::normal,
const Allocator&amp; a = Allocator());
~basic_regex();
basic_regex&amp; operator=(const basic_regex&amp;);
basic_regex&amp; operator=(const charT* ptr);
template &lt;class ST, class SA&gt;
basic_regex&amp; operator=(const basic_string&lt;charT, ST, SA&gt;&amp; p);
// iterators:
const_iterator begin() const;
const_iterator end() const;
// capacity:
size_type size() const;
size_type max_size() const;
bool empty() const;
unsigned mark_count() const;
//
// modifiers:
basic_regex&amp; assign(const basic_regex&amp; that);
basic_regex&amp; assign(const charT* ptr, flag_type f = regex_constants::normal);
basic_regex&amp; assign(const charT* first, const charT* last,
flag_type f = regex_constants::normal);
template &lt;class string_traits, class A&gt;
basic_regex&amp; assign(const basic_string&lt;charT, string_traits, A&gt;&amp; s,
flag_type f = regex_constants::normal);
template &lt;class InputIterator&gt;
basic_regex&amp; assign(InputIterator first, InputIterator last,
flag_type f = regex_constants::normal);
// const operations:
Allocator get_allocator() const;
flag_type getflags() const;
basic_string&lt;charT&gt; str() const;
int compare(basic_regex&amp;) const;
// locale:
locale_type imbue(locale_type loc);
locale_type getloc() const;
// swap
void swap(basic_regex&amp;) throw();
};
template &lt;class charT, class traits, class Allocator&gt;
bool operator == (const basic_regex&lt;charT, traits, Allocator&gt;&amp; lhs,
const basic_regex&lt;charT, traits, Allocator&gt;&amp; rhs);
template &lt;class charT, class traits, class Allocator&gt;
bool operator != (const basic_regex&lt;charT, traits, Allocator&gt;&amp; lhs,
const basic_regex&lt;charT, traits, Allocator&gt;&amp; rhs);
template &lt;class charT, class traits, class Allocator&gt;
bool operator &lt; (const basic_regex&lt;charT, traits, Allocator&gt;&amp; lhs,
const basic_regex&lt;charT, traits, Allocator&gt;&amp; rhs);
template &lt;class charT, class traits, class Allocator&gt;
bool operator &lt;= (const basic_regex&lt;charT, traits, Allocator&gt;&amp; lhs,
const basic_regex&lt;charT, traits, Allocator&gt;&amp; rhs);
template &lt;class charT, class traits, class Allocator&gt;
bool operator &gt;= (const basic_regex&lt;charT, traits, Allocator&gt;&amp; lhs,
const basic_regex&lt;charT, traits, Allocator&gt;&amp; rhs);
template &lt;class charT, class traits, class Allocator&gt;
bool operator &gt; (const basic_regex&lt;charT, traits, Allocator&gt;&amp; lhs,
const basic_regex&lt;charT, traits, Allocator&gt;&amp; rhs);
template &lt;class charT, class io_traits, class re_traits, class Allocator&gt;
basic_ostream&lt;charT, io_traits&gt;&amp;
operator &lt;&lt; (basic_ostream&lt;charT, io_traits&gt;&amp; os,
const basic_regex&lt;charT, re_traits, Allocator&gt;&amp; e);
template &lt;class charT, class traits, class Allocator&gt;
void swap(basic_regex&lt;charT, traits, Allocator&gt;&amp; e1,
basic_regex&lt;charT, traits, Allocator&gt;&amp; e2);
typedef basic_regex&lt;char&gt; regex;
typedef basic_regex&lt;wchar_t&gt; wregex;
} // namespace boost</PRE>
<H3>Description</H3>
<P>Class&nbsp;<EM>basic_regex</EM> has the following public member functions:
</P>
<H4>basic_regex constants</H4>
<PRE>static const regex_constants::syntax_option_type normal = regex_constants::normal;
static const regex_constants::syntax_option_type icase = regex_constants::icase;
static const regex_constants::syntax_option_type nosubs = regex_constants::nosubs;
static const regex_constants::syntax_option_type optimize = regex_constants::optimize;
static const regex_constants::syntax_option_type collate = regex_constants::collate;
static const regex_constants::syntax_option_type ECMAScript = normal;
static const regex_constants::syntax_option_type JavaScript = normal;
static const regex_constants::syntax_option_type JScript = normal;
static const regex_constants::syntax_option_type basic = regex_constants::basic;
static const regex_constants::syntax_option_type extended = regex_constants::extended;
static const regex_constants::syntax_option_type awk = regex_constants::awk;
static const regex_constants::syntax_option_type grep = regex_constants::grep;
static const regex_constants::syntax_option_type egrep = regex_constants::egrep;
static const regex_constants::syntax_option_type sed = basic = regex_constants::sed;
static const regex_constants::syntax_option_type perl = regex_constants::perl;</PRE>
<P>The static constant members are provided as synonyms for the constants declared
in namespace <CODE>boost::regex_constants</CODE>; for each constant of type <CODE>syntax_option_type</CODE>
declared in namespace <CODE>boost::regex_constants</CODE> then a constant with
the same name, type and value is declared within the scope of <CODE>basic_regex</CODE>.</P>
<H4>basic_regex constructors</H4>
<P>In all <CODE>basic_regex</CODE> constructors, a copy of the <CODE>Allocator</CODE>
argument is used for any memory allocation performed by the constructor or
member functions during the lifetime of the object.
</P>
<PRE>basic_regex(const Allocator&amp; a = Allocator());</PRE>
<B>
<P>
Effects:</B> Constructs an object of class <CODE>basic_regex</CODE>. The
postconditions of this function are indicated in the table:<I></I><I></P>
<P>
<DIV align="center">
<P></P>
</I>
<P align="center">
<CENTER>
<TABLE id="Table2" cellSpacing="1" cellPadding="7" width="624" border="1">
<TBODY>
<TR>
<TD vAlign="top" width="50%"><B>
<P>
Element</B>
</P>
</TD>
<TD vAlign="top" width="50%"><B>
<P>
Value </B></P></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>empty()</P>
</TD>
<TD vAlign="top" width="50%">
<P>true</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>size()</P>
</TD>
<TD vAlign="top" width="50%">
<P>0</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>str()</P>
</TD>
<TD vAlign="top" width="50%">
<P>basic_string&lt;charT&gt;()</P>
<P></P>
</TD>
</TR>
</TBODY></TD></TR></TABLE></CENTER>
<P></P>
</DIV><PRE>basic_regex(const charT* p, flag_type f = regex_constants::normal, const Allocator&amp; a = Allocator());</PRE>
<B>
<P>
Requires:</B> <I>p</I> shall not be a null pointer.</P><B>
<P>
Throws: </B><CODE>bad_expression</CODE> if <I>p</I> is not a valid regular
expression.</P><B>
<P>
Effects:</B> Constructs an object of class <CODE>basic_regex</CODE>; the
object's internal finite state machine is constructed from the regular
expression contained in the null-terminated string <I>p</I>, and interpreted
according to the <A href="syntax_option_type.html">option flags</A>&nbsp;specified
in <I>f</I>. The postconditions of this function are indicated in the
table:</P><I>
<P>
<DIV align="center">
<P></P>
</I>
<P align="center">
<CENTER>
<TABLE id="Table3" cellSpacing="1" cellPadding="7" width="624" border="1">
<TBODY>
<TR>
<TD vAlign="top" width="50%"><B>
<P>
Element</B>
</P>
</TD>
<TD vAlign="top" width="50%"><B>
<P>
Value</B> </P></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>empty()</P>
</TD>
<TD vAlign="top" width="50%">
<P>false</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>size()</P>
</TD>
<TD vAlign="top" width="50%">
<P>char_traits&lt;charT&gt;::length(p)</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>str()</P>
</TD>
<TD vAlign="top" width="50%">
<P>basic_string&lt;charT&gt;(p)</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>getflags()</P>
</TD>
<TD vAlign="top" width="50%">
<P>f</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>mark_count()</P>
</TD>
<TD vAlign="top" width="50%">
<P>The number of marked sub-expressions within the expression.</P>
<P></P>
</TD>
</TR>
</TBODY></TD></TR></TABLE></CENTER>
<P></P>
</DIV><PRE>basic_regex(const charT* p1, const charT* p2, flag_type f = regex_constants::normal, const Allocator&amp; a = Allocator());</PRE>
<B>
<P>
Requires:</B> <I>p1 </I>and<I> p2</I> are not null pointers, <CODE>p1 &lt; p2</CODE>.</P><B>
<P>
Throws: </B><CODE>bad_expression</CODE> if [p1,p2) is not a valid regular
expression.</P><B>
<P>
Effects:</B> Constructs an object of class <CODE>basic_regex</CODE>; the
object's internal finite state machine is constructed from the regular
expression contained in the sequence of characters [p1,p2), and interpreted
according the <A href="syntax_option_type.html">option flags</A> specified in <I>f</I>.
The postconditions of this function are indicated in the table:</P><I>
<P>
<DIV align="center">
<P></P>
</I>
<P align="center">
<CENTER>
<TABLE id="Table4" cellSpacing="1" cellPadding="7" width="624" border="1">
<TBODY>
<TR>
<TD vAlign="top" width="50%"><B>
<P>
Element</B>
</P>
</TD>
<TD vAlign="top" width="50%"><B>
<P>
Value</B> </P></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>empty()</P>
</TD>
<TD vAlign="top" width="50%">
<P>false</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>size()</P>
</TD>
<TD vAlign="top" width="50%">
<P>std::distance(p1,p2)</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>str()</P>
</TD>
<TD vAlign="top" width="50%">
<P>basic_string&lt;charT&gt;(p1,p2)</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>getflags()</P>
</TD>
<TD vAlign="top" width="50%">
<P>f</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>mark_count()</P>
</TD>
<TD vAlign="top" width="50%">
<P>The number of marked sub-expressions within the expression.</P>
<P></P>
</TD>
</TR>
</TBODY></TD></TR></TABLE></CENTER>
<P></P>
</DIV><PRE>basic_regex(const charT* p, size_type len, flag_type f, const Allocator&amp; a = Allocator());</PRE>
<B>
<P>
Requires:</B> <I>p</I> shall not be a null pointer, <CODE>len &lt; max_size()</CODE>.</P><B>
<P>
Throws: </B><CODE>bad_expression</CODE> if <I>p</I> is not a valid regular
expression.</P><B>
<P>
Effects:</B> Constructs an object of class <CODE>basic_regex</CODE>; the
object's internal finite state machine is constructed from the regular
expression contained in the sequence of characters [p, p+len), and interpreted
according the <A href="syntax_option_type.html">option flags </A>specified in <I>f</I>.
The postconditions of this function are indicated in the table:</P><I>
<P>
<DIV align="center">
<P></P>
</I>
<P align="center">
<CENTER>
<TABLE id="Table5" cellSpacing="1" cellPadding="7" width="624" border="1">
<TBODY>
<TR>
<TD vAlign="top" width="50%"><B>
<P>
Element</B>
</P>
</TD>
<TD vAlign="top" width="50%"><B>
<P>
Value</B> </P></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>empty()</P>
</TD>
<TD vAlign="top" width="50%">
<P>false</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>size()</P>
</TD>
<TD vAlign="top" width="50%">
<P>len</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>str()</P>
</TD>
<TD vAlign="top" width="50%">
<P>basic_string&lt;charT&gt;(p, len)</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>getflags()</P>
</TD>
<TD vAlign="top" width="50%">
<P>f</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>mark_count()</P>
</TD>
<TD vAlign="top" width="50%">
<P>The number of marked sub-expressions within the expression.</P>
<P></P>
</TD>
</TR>
</TBODY></TD></TR></TABLE></CENTER>
<P></P>
</DIV><PRE>basic_regex(const basic_regex&amp; e);</PRE>
<B>
<P>
Effects:</B> Constructs an object of class <CODE>basic_regex</CODE> as a
copy of the object <I>e</I>. The postconditions of this function are indicated
in the table:</P><I>
<P>
<DIV align="center">
<P></P>
</I>
<P align="center">
<CENTER>
<TABLE id="Table6" cellSpacing="1" cellPadding="7" width="624" border="1">
<TBODY>
<TR>
<TD vAlign="top" width="50%"><B>
<P>
Element</B>
</P>
</TD>
<TD vAlign="top" width="50%"><B>
<P>
Value</B> </P></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>empty()</P>
</TD>
<TD vAlign="top" width="50%">
<P>e.empty()</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>size()</P>
</TD>
<TD vAlign="top" width="50%">
<P>e.size()</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>str()</P>
</TD>
<TD vAlign="top" width="50%">
<P>e.str()</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>getflags()</P>
</TD>
<TD vAlign="top" width="50%">
<P>e.getflags()</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>mark_count()</P>
</TD>
<TD vAlign="top" width="50%">
<P>e.mark_count()</P>
<P></P>
</TD>
</TR>
</TBODY></TD></TR></TABLE></CENTER>
<P></P>
</DIV><PRE>template &lt;class ST, class SA&gt;
basic_regex(const basic_string&lt;charT, ST, SA&gt;&amp; s,
flag_type f = regex_constants::normal, const Allocator&amp; a = Allocator());</PRE>
<B>
<P>
Throws: </B><CODE>bad_expression</CODE> if <I>s</I> is not a valid regular
expression.</P><B>
<P>
Effects:</B> Constructs an object of class <CODE>basic_regex</CODE>; the
object's internal finite state machine is constructed from the regular
expression contained in the string <I>s</I>, and interpreted according to the <A href="syntax_option_type.html">
option flags </A>specified in <I>f</I>. The postconditions of this function
are indicated in the table:</P><I>
<P>
<DIV align="center">
<P></P>
</I>
<P align="center">
<CENTER>
<TABLE id="Table7" cellSpacing="1" cellPadding="7" width="624" border="1">
<TBODY>
<TR>
<TD vAlign="top" width="50%"><B>
<P>
Element</B>
</P>
</TD>
<TD vAlign="top" width="50%"><B>
<P>
Value</B> </P></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>empty()</P>
</TD>
<TD vAlign="top" width="50%">
<P>false</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>size()</P>
</TD>
<TD vAlign="top" width="50%">
<P>s.size()</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>str()</P>
</TD>
<TD vAlign="top" width="50%">
<P>s</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>getflags()</P>
</TD>
<TD vAlign="top" width="50%">
<P>f</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>mark_count()</P>
</TD>
<TD vAlign="top" width="50%">
<P>The number of marked sub-expressions within the expression.</P>
<P></P>
</TD>
</TR>
</TBODY></TD></TR></TABLE></CENTER>
<P></P>
</DIV><PRE>template &lt;class ForwardIterator&gt;
basic_regex(ForwardIterator first, ForwardIterator last,
flag_type f = regex_constants::normal, const Allocator&amp; a = Allocator());</PRE>
<B>
<P>
Throws: </B><CODE>bad_expression</CODE> if the sequence <I>[first, last)</I>
is not a valid regular expression.</P><B>
<P>
Effects:</B> Constructs an object of class <CODE>basic_regex</CODE>; the
object's internal finite state machine is constructed from the regular
expression contained in the sequence of characters [first, last), and
interpreted according to the <A href="syntax_option_type.html">option flags </A>
specified in <I>f</I>. The postconditions of this function are indicated in the
table:</P><I>
<P>
<DIV align="center">
<P></P>
</I>
<P align="center">
<CENTER>
<TABLE id="Table8" cellSpacing="1" cellPadding="7" width="624" border="1">
<TBODY>
<TR>
<TD vAlign="top" width="50%"><B>
<P>
Element</B>
</P>
</TD>
<TD vAlign="top" width="50%"><B>
<P>
Value</B> </P></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>empty()</P>
</TD>
<TD vAlign="top" width="50%">
<P>false</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>size()</P>
</TD>
<TD vAlign="top" width="50%">
<P>distance(first,last)</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>str()</P>
</TD>
<TD vAlign="top" width="50%">
<P>basic_string&lt;charT&gt;(first,last)</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>getflags()</P>
</TD>
<TD vAlign="top" width="50%">
<P>f</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>mark_count()</P>
</TD>
<TD vAlign="top" width="50%">
<P>The number of marked sub-expressions within the expression.</P>
<P></P>
</TD>
</TR>
</TBODY></TD></TR></TABLE></CENTER>
<P></P>
</DIV><PRE>basic_regex&amp; operator=(const basic_regex&amp; e);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>assign(e.str(), e.getflags())</CODE>.</P><PRE>basic_regex&amp; operator=(const charT* ptr);</PRE>
<B>
<P>
Requires:</B> <I>p</I> shall not be a null pointer.</P><B>
<P>
Effects:</B> Returns the result of <CODE>assign(ptr)</CODE>.</P><PRE>template &lt;class ST, class SA&gt;
basic_regex&amp; operator=(const basic_string&lt;charT, ST, SA&gt;&amp; p);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>assign(p)</CODE>.</P>
<H4>basic_regex iterators</H4>
<PRE>const_iterator begin() const;</PRE>
<B>
<P>
Effects:</B> Returns a starting iterator to a sequence of characters
representing the regular expression.</P><PRE>const_iterator end() const;</PRE>
<B>
<P>
Effects:</B> Returns termination iterator to a sequence of characters
representing the regular expression.</P>
<H4>basic_regex capacity</H4>
<PRE>size_type size() const;</PRE>
<B>
<P>
Effects:</B> Returns the length of the sequence of characters representing
the regular expression.</P><PRE>size_type max_size() const;</PRE>
<B>
<P>
Effects:</B> Returns the maximum length of the sequence of characters
representing the regular expression.</P><PRE>bool empty() const;</PRE>
<B>
<P>
Effects:</B> Returns <B>true</B> if the object does not contain a valid
regular expression, otherwise <B>false</B>.</P><PRE>unsigned mark_count() const;</PRE>
<B>
<P>
Effects:</B> Returns the number of marked sub-expressions within the regular
expresion.</P>
<H4>basic_regex assign</H4>
<PRE>basic_regex&amp; assign(const basic_regex&amp; that);</PRE>
<B>
<P>
Effects:</B> Returns <CODE>assign(that.str(), that.getflags())</CODE>.</P><PRE>basic_regex&amp; assign(const charT* ptr, flag_type f = regex_constants::normal);</PRE>
<B>
<P>
Effects:</B> Returns <CODE>assign(string_type(ptr), f)</CODE>.</P><PRE>basic_regex&amp; assign(const charT* first, const charT* last,
flag_type f = regex_constants::normal);</PRE>
<B>
<P>
Effects:</B> Returns <CODE>assign(string_type(first, last), f)</CODE>.</P><PRE>template &lt;class string_traits, class A&gt;
basic_regex&amp; assign(const basic_string&lt;charT, string_traits, A&gt;&amp; s,
flag_type f = regex_constants::normal);</PRE>
<B>
<P>
Throws: </B><CODE>bad_expression</CODE> if <I>s</I> is not a valid regular
expression.</P><B>
<P>
Returns:</B> <CODE>*this</CODE>.</P><B>
<P>
Effects:</B> Assigns the regular expression contained in the string <I>s</I>,
interpreted according the <A href="syntax_option_type.html">option flags</A> specified
in <I>f</I>. The postconditions of this function are indicated in the
table:</P><I>
<P>
<DIV align="center">
<P></P>
</I>
<P align="center">
<CENTER>
<TABLE id="Table9" cellSpacing="1" cellPadding="7" width="624" border="1">
<TBODY>
<TR>
<TD vAlign="top" width="50%"><B>
<P>
Element</B>
</P>
</TD>
<TD vAlign="top" width="50%"><B>
<P>
Value</B> </P></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>empty()</P>
</TD>
<TD vAlign="top" width="50%">
<P>false</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>size()</P>
</TD>
<TD vAlign="top" width="50%">
<P>s.size()</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>str()</P>
</TD>
<TD vAlign="top" width="50%">
<P>s</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>getflags()</P>
</TD>
<TD vAlign="top" width="50%">
<P>f</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>mark_count()</P>
</TD>
<TD vAlign="top" width="50%">
<P>The number of marked sub-expressions within the expression.</P>
<P></P>
</TD>
</TR>
</TBODY></TD></TR></TABLE></CENTER>
<P></P>
</DIV><PRE>template &lt;class InputIterator&gt;
basic_regex&amp; assign(InputIterator first, InputIterator last,
flag_type f = regex_constants::normal);</PRE>
<B>
<P>
Requires:</B> The type InputIterator corresponds to the Input Iterator
requirements (24.1.1).</P><B>
<P>
Effects:</B> Returns <CODE>assign(string_type(first, last), f)</CODE>.</P>
<H4>basic_regex constant operations</H4>
<PRE>Allocator get_allocator() const;</PRE>
<B>
<P>
Effects:</B> Returns a copy of the Allocator that was passed to the object's
constructor.</P><PRE>flag_type getflags() const;</PRE>
<B>
<P>
Effects:</B> Returns a copy of the regular expression syntax flags that were
passed to the object's constructor, or the last call to <CODE>assign.</P></CODE><PRE>basic_string&lt;charT&gt; str() const;</PRE>
<B>
<P>
Effects:</B> Returns a copy of the character sequence passed to the object's
constructor, or the last call to <CODE>assign.</P></CODE><PRE>int compare(basic_regex&amp; e)const;</PRE>
<B>
<P>
Effects:</B> If <CODE>getflags() == e.getflags()</CODE> then returns <CODE>str().compare(e.str())</CODE>,
otherwise returns <CODE>getflags() - e.getflags()</CODE>.</P>
<H4>basic_regex locale</H4>
<PRE>locale_type imbue(locale_type l);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>traits_inst.imbue(l)</CODE> where <CODE>
traits_inst </CODE>is a (default initialized) instance of the template
parameter <CODE>traits</CODE> stored within the object. Calls to imbue
invalidate any currently contained regular expression.</P><B>
<P>
Postcondition:</B> <CODE>empty() == true</CODE>.</P><PRE>locale_type getloc() const;</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>traits_inst.getloc()</CODE> where <CODE>
traits_inst </CODE>is a (default initialized) instance of the template
parameter <CODE>traits</CODE> stored within the object.</P>
<H4>basic_regex swap</H4>
<PRE>void swap(basic_regex&amp; e) throw();</PRE>
<B>
<P>
Effects:</B> Swaps the contents of the two regular expressions. </P><B>
<P>
Postcondition:</B> <CODE>*this</CODE> contains the characters that were in <I>e</I>,
<I>e </I>contains the regular expression that was in <CODE>*this</CODE>. </P><B>
<P>
Complexity:</B> constant time. </P>
<H4>basic_regex non-member functions</H4>
<H5>basic_regex non-member comparison operators&nbsp;</H5>
<PRE>template &lt;class charT, class traits, class Allocator&gt;
bool operator == (const basic_regex&lt;charT, traits, Allocator&gt;&amp; lhs,
const basic_regex&lt;charT, traits, Allocator&gt;&amp; rhs);</PRE>
<B>
<P>
Effects:</B> Returns <CODE>lhs.compare(rhs) == 0</CODE>.</P><PRE>template &lt;class charT, class traits, class Allocator&gt;
bool operator != (const basic_regex&lt;charT, traits, Allocator&gt;&amp; lhs,
const basic_regex&lt;charT, traits, Allocator&gt;&amp; rhs);</PRE>
<B>
<P>
Effects:</B> Returns <CODE>lhs.compare(rhs) != 0</CODE>.</P><PRE>template &lt;class charT, class traits, class Allocator&gt;
bool operator &lt; (const basic_regex&lt;charT, traits, Allocator&gt;&amp; lhs,
const basic_regex&lt;charT, traits, Allocator&gt;&amp; rhs);</PRE>
<B>
<P>
Effects:</B> Returns <CODE>lhs.compare(rhs) &lt; 0</CODE>.</P><PRE>template &lt;class charT, class traits, class Allocator&gt;
bool operator &lt;= (const basic_regex&lt;charT, traits, Allocator&gt;&amp; lhs,
const basic_regex&lt;charT, traits, Allocator&gt;&amp; rhs);</PRE>
<B>
<P>
Effects:</B> Returns <CODE>lhs.compare(rhs) &lt;= 0</CODE>.</P><PRE>template &lt;class charT, class traits, class Allocator&gt;
bool operator &gt;= (const basic_regex&lt;charT, traits, Allocator&gt;&amp; lhs,
const basic_regex&lt;charT, traits, Allocator&gt;&amp; rhs);</PRE>
<B>
<P>
Effects:</B> Returns <CODE>lhs.compare(rhs) &gt;= 0</CODE>.</P><PRE>template &lt;class charT, class traits, class Allocator&gt;
bool operator &gt; (const basic_regex&lt;charT, traits, Allocator&gt;&amp; lhs,
const basic_regex&lt;charT, traits, Allocator&gt;&amp; rhs);</PRE>
<B>
<P>
Effects:</B> Returns <CODE>lhs.compare(rhs) &gt; 0</CODE>.</P>
<H5>basic_regex inserter.</H5>
<PRE>template &lt;class charT, class io_traits, class re_traits, class Allocator&gt;
basic_ostream&lt;charT, io_traits&gt;&amp;
operator &lt;&lt; (basic_ostream&lt;charT, io_traits&gt;&amp; os
const basic_regex&lt;charT, re_traits, Allocator&gt;&amp; e);</PRE>
<B>
<P>
Effects:</B> Returns (os &lt;&lt; e.str()).</P>
<H5>basic_regex non-member swap</H5>
<PRE>template &lt;class charT, class traits, class Allocator&gt;
void swap(basic_regex&lt;charT, traits, Allocator&gt;&amp; lhs,
basic_regex&lt;charT, traits, Allocator&gt;&amp; rhs);</PRE>
<B>
<P>
Effects:</B> calls <CODE>lhs.swap(rhs)</CODE>.</P>
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

86
doc/contacts.html Normal file
View File

@ -0,0 +1,86 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Contacts</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">Contacts and Acknowledgements</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<P>The author can be contacted at <A href="mailto:John_Maddock@compuserve.com">John_Maddock@compuserve.com</A>,
the home page for this library is at <A href="http://ourworld.compuserve.com/homepages/John_Maddock/regexpp.htm">
http://ourworld.compuserve.com/homepages/John_Maddock/regexpp.htm</A>, and
the official boost version can be obtained from <A href="../libraries.htm">www.boost.org/libraries.htm</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<72> 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>Useful further information can be found at:
</P>
<P>A short tutorial on regular expressions <A href="http://www.devshed.com/Server_Side/Administration/RegExp/">
can be found here</A>.</P>
<P>The <A href="http://www.opengroup.org/onlinepubs/7908799/toc.htm">Open Unix
Specification</A> contains a wealth of useful material, including the
regular expression syntax, and specifications for <A href="http://www.opengroup.org/onlinepubs/7908799/xsh/regex.h.html">
&lt;regex.h&gt;</A> and <A href="http://www.opengroup.org/onlinepubs/7908799/xsh/nl_types.h.html">
&lt;nl_types.h&gt;</A>.
</P>
<P>The <A href="http://www.cs.ucr.edu/~stelo/pattern.html">Pattern Matching Pointers</A>
site is a "must visit" resource for anyone interested in pattern matching.
</P>
<P><A href="http://glimpse.cs.arizona.edu/">Glimpse and Agrep</A>, use a
simplified regular expression syntax to achieve faster search times.
</P>
<P><A href="http://glimpse.cs.arizona.edu/udi.html">Udi Manber</A> and <A href="http://www.dcc.uchile.cl/~rbaeza/">
Ricardo Baeza-Yates</A>
both have a selection of useful pattern matching papers available from their
respective web sites.
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

107
doc/examples.html Normal file
View File

@ -0,0 +1,107 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Examples</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">Examples</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<P>There are three demo applications that ship with this library, they all come
with makefiles for Borland, Microsoft and gcc compilers, otherwise you will
have to create your own makefiles.
</P>
<H5>regress.exe:
</H5>
<P>A regression test application that gives the matching/searching algorithms a
full workout. The presence of this program is your guarantee that the library
will behave as claimed - at least as far as those items tested are concerned -
if anyone spots anything that isn't being tested I'd be glad to hear about it.
</P>
<P>Files: <A href="../test/regress/parse.cpp">parse.cpp</A>, <A href="../test/regress/regress.cpp">
regress.cpp</A>, <A href="../test/regress/tests.cpp">tests.cpp</A>.
</P>
<H5>jgrep.exe
</H5>
<P>A simple grep implementation, run with no command line options to find out its
usage. Look at <A href="../src/fileiter.cpp">fileiter.cpp</A>/fileiter.hpp and
the mapfile class to see an example of a "smart" bidirectional iterator that
can be used with boost.regex or any other STL algorithm.
</P>
<P>Files: <A href="../example/jgrep/jgrep.cpp">jgrep.cpp</A>, <A href="../example/jgrep/main.cpp">
main.cpp</A>.
</P>
<H5>timer.exe
</H5>
<P>A simple interactive expression matching application, the results of all
matches are timed, allowing the programmer to optimize their regular
expressions where performance is critical.
</P>
<P>Files: <A href="../example/timer/regex_timer.cpp">regex_timer.cpp</A>.
</P>
<H5>Code snippets</H5>
<P>The snippets examples contain the code examples used in the documentation:</P>
<P><A href="../example/snippets/credit_card_example.cpp">credit_card_example.cpp</A>:
Credit card number formatting code.</P>
<P><A href="../example/snippets/partial_regex_grep.cpp">partial_regex_grep.cpp</A>:
Search example using partial matches.</P>
<P><A href="../example/snippets/partial_regex_match.cpp">partial_regex_match.cpp</A>:
regex_match example using partial matches.</P>
<P><A href="../example/snippets/regex_grep_example_1.cpp">regex_grep_example_1.cpp</A>:
regex_grep example 1: searches a cpp file for class definitions.</P>
<P><A href="../example/snippets/regex_grep_example_2.cpp">regex_grep_example_2.cpp</A>:
regex_grep example 2: searches a cpp file for class definitions, using a global
callback function.
</P>
<P><A href="../example/snippets/regex_grep_example_3.cpp">regex_grep_example_3.cpp</A>:
regex_grep example 2: searches a cpp file for class definitions, using a bound
member function callback.</P>
<P><A href="../example/snippets/regex_grep_example_4.cpp">regex_grep_example_4.cpp</A>:
regex_grep example 2: searches a cpp file for class definitions, using a C++
Builder closure as a callback.</P>
<P><A href="../example/snippets/regex_match_example.cpp">regex_match_example.cpp</A>:
ftp based regex_match example.</P>
<P><A href="../example/snippets/regex_merge_example.cpp">regex_merge_example.cpp</A>:
regex_merge example: converts a C++ file to syntax highlighted HTML.</P>
<P><A href="../example/snippets/regex_replace_example.cpp">regex_replace_example.cpp</A>:
regex_replace example: converts a C++ file to syntax highlighted HTML</P>
<P><A href="../example/snippets/regex_search_example.cpp">regex_search_example.cpp</A>:
regex_search example: searches a cpp file for class definitions.</P>
<P><A href="../example/snippets/regex_split_example_1.cpp">regex_split_example_1.cpp</A>:
regex_split example: split a string into tokens.</P>
<P><A href="../example/snippets/regex_split_example_2.cpp">regex_split_example_2.cpp</A>
: regex_split example: spit out linked URL's.
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

118
doc/faq.html Normal file
View File

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

217
doc/format_syntax.html Normal file
View File

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

51
doc/headers.html Normal file
View File

@ -0,0 +1,51 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Headers</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">Headers</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<P>There are two main headers used by this library: &lt;boost/regex.hpp&gt;
provides full access to the entire library, while &lt;boost/cregex.hpp&gt;
provides access to just the high level class RegEx, and the POSIX API
functions.
</P>
<P>There is also a header containing only forward declarations
&lt;boost/regex_fwd.hpp&gt; for use when an interface is dependent upon
boost::basic_regex, but otherwise does not need the full definitions.</P>
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

44
doc/history.html Normal file
View File

@ -0,0 +1,44 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: History</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">History</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<P>Todo.</P>
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

44
doc/implementation.html Normal file
View File

@ -0,0 +1,44 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Implementation</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">Implementation</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<P>Todo.</P>
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

119
doc/index.html Normal file
View File

@ -0,0 +1,119 @@
<!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: Index</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<p></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 style="WIDTH: 353px">
<h1 align="center">Boost.Regex</h1>
<h2 align="center">Index</h2>
</td>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</tr>
</table>
<br>
<br>
<hr>
<h2>Contents</h2>
<dl class="index">
<dt><a href="introduction.html">Overview</a></dt> <dt><a href="install.html">Installation</a></dt>
<dd>
<dl class="index">
<dt><a href="install.html#bcb">Borland C++ Builder</a></dt> <dt><a href="install.html#vc">
Microsoft Visual C++</a></dt> <dt><a href="install.html#gcc">GNU G++</a></dt>
<dt><a href="install.html#sun">Sun Forte Compiler</a></dt> <dt><a href="install.html#other">
Other compilers (building with bjam)</a></dt>
</dl>
</dd>
<dt>Reference</dt>
<dd>
<dl class="index">
<dt>Types</dt>
<dd>
<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>
</dl>
</dd>
<dt>Algorithms</dt>
<dd>
<dl class="index">
<dt><a href="regex_match.html">regex_match</a></dt> <dt><a href="regex_search.html">regex_search</a></dt>
<dt><a href="regex_replace.html">regex_replace</a></dt>
</dl>
</dd>
<dt>Iterators</dt>
<dd>
<dl class="index">
<dt><a href="regex_iterator.html">regex_iterator</a></dt>
</dl>
</dd>
<dt>Misc.</dt>
<dd>
<dl class="index">
<dt><a href="posix_api.html">POSIX API Compatibility Functions</a></dt>
<dt><a href="partial_matches.html">Partial matches</a></dt>
<dt><a href="synatx.html">Regular Expression Syntax</a></dt>
<dt><a href="format_syntax.html">Format String Syntax</a></dt>
</dl>
</dd>
<dt>Deprecated interfaces</dt>
<dd>
<dl class="index">
<dt><a href="regbase.html">class regbase</a></dt> <dt><a href="reg_expression.html">class
template reg_expression</a></dt> <dt><a href="regex_grep.html">Algorithm
regex_grep</a></dt> <dt><a href="regex_format.html">Algorithm regex_format</a></dt>
<dt><a href="regex_merge.html">Algorithm regex_merge</a></dt> <dt><a href="regex_split.html">
Algorithm regex_split</a></dt>
<dt><a href="regex.html">class RegEx</a></dt>
</dl>
</dd>
</dl>
</dd>
<dt><a href="faq.html">FAQ</a></dt>
<dt>Appendix</dt>
<dd>
<dl class="index">
<dt><a href="implementation.html">Implementation</a></dt>
<dt><a href="thread_safety.html">Thread Safety</a></dt>
<dt><a href="localisation.html">Localisation</a></dt>
<dt><a href="examples.html">Examples</a></dt>
<dt><a href="headers.html">Headers</a></dt>
<dt><a href="redistributables.html">Redistributables and Library Names</a></dt>
<dt><a href="history.html">History</a></dt>
<dt><a href="contacts.html">Contacts and Acknowledgements</a></dt>
</dl>
</dd>
</dl>
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
<p><i>&copy; Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
<p align="left"><i>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</i></p>
</body>
</html>

236
doc/install.html Normal file
View File

@ -0,0 +1,236 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Index</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">Installation</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<P><EM>[ </EM><STRONG><I>Important</I></STRONG><EM>: If you are upgrading from the
2.x version of this library then you will find a number of changes to the
documented header names and library interfaces, existing code should still
compile unchanged however - see </EM><A href="appendix.htm#upgrade"><FONT color="#0000ff">
<EM>Note for Upgraders</EM></FONT></A><EM>. ]</EM></P>
<P>When you extract the library from its zip file, you must preserve its internal
directory structure (for example by using the -d option when extracting). If
you didn't do that when extracting, then you'd better stop reading this, delete
the files you just extracted, and try again!
</P>
<P>This library should not need configuring before use; most popular
compilers/standard libraries/platforms are already supported "as is". If you do
experience configuration problems, or just want to test the configuration with
your compiler, then the process is the same as for all of boost; see the <A href="../config/config.htm">
configuration library documentation</A>.</P>
<P>The library will encase all code inside namespace boost.
</P>
<P>Unlike some other template libraries, this library consists of a mixture of
template code (in the headers) and static code and data (in cpp files).
Consequently it is necessary to build the library's support code into a library
or archive file before you can use it, instructions for specific platforms are
as follows:
</P>
<P><B><A name="bcb"></A>Borland C++ Builder:</B>
</P>
<UL>
<LI>
Open up a console window and change to the &lt;boost&gt;\libs\regex\build
directory.
<LI>
Select the appropriate makefile (bcb4.mak for C++ Builder 4, bcb5.mak for C++
Builder 5, and bcb6.mak for C++ Builder 6).
<LI>
Invoke the makefile (pass the full path to your version of make if you have
more than one version installed, the makefile relies on the path to make to
obtain your C++ Builder installation directory and tools) for example:
</LI>
</UL>
<PRE>make -fbcb5.mak</PRE>
<P>The build process will build a variety of .lib and .dll files (the exact number
depends upon the version of Borland's tools you are using) the .lib and dll
files will be in a sub-directory called bcb4 or bcb5 depending upon the
makefile used. To install the libraries into your development system use:</P>
<P>make -fbcb5.mak install</P>
<P>library files will be copied to &lt;BCROOT&gt;/lib and the dll's to
&lt;BCROOT&gt;/bin, where &lt;BCROOT&gt; corresponds to the install path of
your Borland C++ tools.
</P>
<P>You may also remove temporary files created during the build process (excluding
lib and dll files) by using:</P>
<P>make -fbcb5.mak clean</P>
<P>Finally when you use regex++ it is only necessary for you to add the
&lt;boost&gt; root director to your list of include directories for that
project. It is not necessary for you to manually add a .lib file to the
project; the headers will automatically select the correct .lib file for your
build mode and tell the linker to include it. There is one caveat however: the
library can not tell the difference between VCL and non-VCL enabled builds when
building a GUI application from the command line, if you build from the command
line with the 5.5 command line tools then you must define the pre-processor
symbol _NO_VCL in order to ensure that the correct link libraries are selected:
the C++ Builder IDE normally sets this automatically. Hint, users of the 5.5
command line tools may want to add a -D_NO_VCL to bcc32.cfg in order to set
this option permanently.
</P>
<P>If you would prefer to do a static link to the regex libraries even when using
the dll runtime then define BOOST_REGEX_STATIC_LINK, and if you want to
suppress automatic linking altogether (and supply your own custom build of the
lib) then define BOOST_REGEX_NO_LIB.</P>
<P>If you are building with C++ Builder 6, you will find that
&lt;boost/regex.hpp&gt; can not be used in a pre-compiled header (the actual
problem is in &lt;locale&gt; which gets included by &lt;boost/regex.hpp&gt;),
if this causes problems for you, then try defining BOOST_NO_STD_LOCALE when
building, this will disable some features throughout boost, but may save you a
lot in compile times!</P>
<P><B><A name="vc"></A>Microsoft Visual C++ 6</B><STRONG> and 7</STRONG></P>
<P>You need version 6 of MSVC to build this library. If you are using VC5 then you
may want to look at one of the previous releases of this <A href="http://ourworld.compuserve.com/homepages/john_maddock/regexpp.htm">
library</A>
</P>
<P>Open up a command prompt, which has the necessary MSVC environment variables
defined (for example by using the batch file Vcvars32.bat installed by the
Visual Studio installation), and change to the &lt;boost&gt;\libs\regex\build
directory.
</P>
<P>Select the correct makefile - vc6.mak for "vanilla" Visual C++ 6 or
vc6-stlport.mak if you are using STLPort.</P>
<P>Invoke the makefile like this:</P>
<P>nmake -fvc6.mak</P>
<P>You will now have a collection of lib and dll files in a "vc6" subdirectory, to
install these into your development system use:</P>
<P>nmake -fvc6.mak install</P>
<P>The lib files will be copied to your &lt;VC6&gt;\lib directory and the dll
files to &lt;VC6&gt;\bin, where &lt;VC6&gt; is the root of your Visual C++ 6
installation.</P>
<P>You can delete all the temporary files created during the build (excluding lib
and dll files) using:</P>
<P>nmake -fvc6.mak clean
</P>
<P>Finally when you use regex++ it is only necessary for you to add the
&lt;boost&gt; root directory to your list of include directories for that
project. It is not necessary for you to manually add a .lib file to the
project; the headers will automatically select the correct .lib file for your
build mode and tell the linker to include it.
</P>
<P>Note that if you want to statically link to the regex library when using the
dynamic C++ runtime, define BOOST_REGEX_STATIC_LINK when building your project
(this only has an effect for release builds). If you want to add the source
directly to your project then define BOOST_REGEX_NO_LIB to disable automatic
library selection.</P>
<P><STRONG><I>Important</I></STRONG><EM>: there have been some reports of
compiler-optimisation bugs affecting this library, (particularly with VC6
versions prior to service patch 5) the workaround is to build the library using
/Oityb1 rather than /O2. That is to use all optimisation settings except /Oa.
This problem is reported to affect some standard library code as well (in fact
I'm not sure if the problem is with the regex code or the underlying standard
library), so it's probably worthwhile applying this workaround in normal
practice in any case.</EM></P>
<P>Note: if you have replaced the C++ standard library that comes with VC6, then
when you build the library you must ensure that the environment variables
"INCLUDE" and "LIB" have been updated to reflect the include and library paths
for the new library - see vcvars32.bat (part of your Visual Studio
installation) for more details. Alternatively if STLPort is in c:/stlport then
you could use:</P>
<P>nmake INCLUDES="-Ic:/stlport/stlport" XLFLAGS="/LIBPATH:c:/stlport/lib"
-fvc6-stlport.mak</P>
<P>If you are building with the full STLPort v4.x, then use the vc6-stlport.mak
file provided and set the environment variable STLPORT_PATH to point to the
location of your STLport installation (Note that the full STLPort libraries
appear not to support single-thread static builds).
<BR>
&nbsp;
<BR>
&nbsp;
</P>
<P><B><A name="gcc"></A>GCC(2.95 and 3.x)</B>
</P>
<P>There is a conservative makefile for the g++ compiler. From the command prompt
change to the &lt;boost&gt;/libs/regex/build directory and type:
</P>
<P>make -fgcc.mak
</P>
<P>At the end of the build process you should have a gcc sub-directory containing
release and debug versions of the library (libboost_regex.a and
libboost_regex_debug.a). When you build projects that use regex++, you will
need to add the boost install directory to your list of include paths and add
&lt;boost&gt;/libs/regex/build/gcc/libboost_regex.a to your list of library
files.
</P>
<P>There is also a makefile to build the library as a shared library:</P>
<P>make -fgcc-shared.mak</P>
<P>which will build libboost_regex.so and libboost_regex_debug.so.</P>
<P>Both of the these makefiles support the following environment variables:</P>
<P>CXXFLAGS: extra compiler options - note that this applies to both the debug and
release builds.</P>
<P>INCLUDES: additional include directories.</P>
<P>LDFLAGS: additional linker options.</P>
<P>LIBS: additional library files.</P>
<P>For the more adventurous there is a configure script in
&lt;boost&gt;/libs/config; see the <A href="../config/config.htm">config library
documentation</A>.</P>
<P><B><A name="sun"></A>Sun Workshop 6.1</B></P>
<P>There is a makefile for the sun (6.1) compiler (C++ version 3.12). From the
command prompt change to the &lt;boost&gt;/libs/regex/build directory and type:
</P>
<P>dmake -f sunpro.mak
</P>
<P>At the end of the build process you should have a sunpro sub-directory
containing single and multithread versions of the library (libboost_regex.a,
libboost_regex.so, libboost_regex_mt.a and libboost_regex_mt.so). When you
build projects that use regex++, you will need to add the boost install
directory to your list of include paths and add
&lt;boost&gt;/libs/regex/build/sunpro/ to your library search path.
</P>
<P>Both of the these makefiles support the following environment variables:</P>
<P>CXXFLAGS: extra compiler options - note that this applies to both the single
and multithreaded builds.</P>
<P>INCLUDES: additional include directories.</P>
<P>LDFLAGS: additional linker options.</P>
<P>LIBS: additional library files.</P>
<P>LIBSUFFIX: a suffix to mangle the library name with (defaults to nothing).</P>
<P>This makefile does not set any architecture specific options like -xarch=v9,
you can set these by defining the appropriate macros, for example:</P>
<P>dmake CXXFLAGS="-xarch=v9" LDFLAGS="-xarch=v9" LIBSUFFIX="_v9" -f sunpro.mak</P>
<P>will build v9 variants of the regex library named libboost_regex_v9.a etc.</P>
<P><B><A name="other"></A>Other compilers:</B>
</P>
<P>There is a generic makefile (<A href="build/generic.mak">generic.mak</A>)
provided in &lt;boost-root&gt;/libs/regex/build - see that makefile for details
of environment variables that need to be set before use. Alternatively you can
using the <A href="../../tools/build/index.html">Jam based build system</A>. If
you need to configure the library for your platform, then refer to the <A href="../config/config.htm">
config library documentation</A>
.
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

174
doc/introduction.html Normal file
View File

@ -0,0 +1,174 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Introduction</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">Introduction</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<P>Regular expressions are a form of pattern-matching that are often used in text
processing; many users will be familiar with the Unix utilities <I>grep</I>, <I>sed</I>
and <I>awk</I>, and the programming language <I>perl</I>, each of which make
extensive use of regular expressions. Traditionally C++ users have been limited
to the POSIX C API's for manipulating regular expressions, and while regex++
does provide these API's, they do not represent the best way to use the
library. For example regex++ can cope with wide character strings, or search
and replace operations (in a manner analogous to either sed or perl), something
that traditional C libraries can not do.</P>
<P>The class <A href="basic_regex.html">boost::basic_regex</A> is the key class in
this library; it represents a "machine readable" regular expression, and is
very closely modelled on std::basic_string, think of it as a string plus the
actual state-machine required by the regular expression algorithms. Like
std::basic_string there are two typedefs that are almost always the means by
which this class is referenced:</P>
<pre><B>namespace </B>boost{
<B>template</B> &lt;<B>class</B> charT,
<B> class</B> traits = regex_traits&lt;charT&gt;,
<B>class</B> Allocator = std::allocator&lt;charT&gt; &gt;
<B>class</B> basic_regex;
<B>typedef</B> basic_regex&lt;<B>char</B>&gt; regex;
<B>typedef</B> basic_regex&lt;<B>wchar_t&gt;</B> wregex;
}</pre>
<P>To see how this library can be used, imagine that we are writing a credit card
processing application. Credit card numbers generally come as a string of
16-digits, separated into groups of 4-digits, and separated by either a space
or a hyphen. Before storing a credit card number in a database (not necessarily
something your customers will appreciate!), we may want to verify that the
number is in the correct format. To match any digit we could use the regular
expression [0-9], however ranges of characters like this are actually locale
dependent. Instead we should use the POSIX standard form [[:digit:]], or the
regex++ and perl shorthand for this \d (note that many older libraries tended
to be hard-coded to the C-locale, consequently this was not an issue for them).
That leaves us with the following regular expression to validate credit card
number formats:</P>
<P>(\d{4}[- ]){3}\d{4}</P>
<P>Here the parenthesis act to group (and mark for future reference)
sub-expressions, and the {4} means "repeat exactly 4 times". This is an example
of the extended regular expression syntax used by perl, awk and egrep. Regex++
also supports the older "basic" syntax used by sed and grep, but this is
generally less useful, unless you already have some basic regular expressions
that you need to reuse.</P>
<P>Now lets take that expression and place it in some C++ code to validate the
format of a credit card number:</P>
<PRE><B>bool</B> validate_card_format(<B>const</B> std::string s)
{
<B>static</B> <B>const</B> <A href="basic_regex.html">boost::regex</A> e("(\\d{4}[- ]){3}\\d{4}");
<B>return</B> <A href="regex_match.html">regex_match</A>(s, e);
}</PRE>
<P>Note how we had to add some extra escapes to the expression: remember that the
escape is seen once by the C++ compiler, before it gets to be seen by the
regular expression engine, consequently escapes in regular expressions have to
be doubled up when embedding them in C/C++ code. Also note that all the
examples assume that your compiler supports Koenig lookup, if yours doesn't
(for example VC6), then you will have to add some boost:: prefixes to some of
the function calls in the examples.</P>
<P>Those of you who are familiar with credit card processing, will have realised
that while the format used above is suitable for human readable card numbers,
it does not represent the format required by online credit card systems; these
require the number as a string of 16 (or possibly 15) digits, without any
intervening spaces. What we need is a means to convert easily between the two
formats, and this is where search and replace comes in. Those who are familiar
with the utilities <I>sed</I> and <I>perl</I> will already be ahead here; we
need two strings - one a regular expression - the other a "<A href="format_syntax.html">format
string</A>" that provides a description of the text to replace the match
with. In regex++ this search and replace operation is performed with the
algorithm regex_replace, for our credit card example we can write two algorithms
like this to provide the format conversions:</P>
<PRE><I>// match any format with the regular expression:
</I><B>const</B> boost::regex e("\\A(\\d{3,4})[- ]?(\\d{4})[- ]?(\\d{4})[- ]?(\\d{4})\\z");
<B>const</B> std::string machine_format("\\1\\2\\3\\4");
<B>const</B> std::string human_format("\\1-\\2-\\3-\\4");
std::string machine_readable_card_number(<B>const</B> std::string s)
{
<B>return</B> <A href="regex_replace.html">regex_replace</A>(s, e, machine_format, boost::match_default | boost::format_sed);
}
std::string human_readable_card_number(<B>const</B> std::string s)
{
<B>return</B> <A href="regex_replace.html">regex_replace</A>(s, e, human_format, boost::match_default | boost::format_sed);
}</PRE>
<P>Here we've used marked sub-expressions in the regular expression to split out
the four parts of the card number as separate fields, the format string then
uses the sed-like syntax to replace the matched text with the reformatted
version.</P>
<P>In the examples above, we haven't directly manipulated the results of a regular
expression match, however in general the result of a match contains a number of
sub-expression matches in addition to the overall match. When the library needs
to report a regular expression match it does so using an instance of the class <A href="match_results.html">
match_results</A>, as before there are typedefs of this class for the most
common cases:
</P>
<PRE><B>namespace </B>boost{
<B>typedef</B> match_results&lt;<B>const</B> <B>char</B>*&gt; cmatch;
<B>typedef</B> match_results&lt;<B>const</B> <B>wchar_t</B>*&gt; wcmatch;
<STRONG>typedef</STRONG> match_results&lt;std::string::const_iterator&gt; smatch;
<STRONG>typedef</STRONG> match_results&lt;std::wstring::const_iterator&gt; wsmatch;
}</PRE>
<P>The algorithms <A href="regex_search.html">regex_search</A> and <A href="regex_grep.html">
regex_grep</A> (i.e. finding all matches in a string) make use of
match_results to report what matched.</P>
<P>Note that these algorithms are not restricted to searching regular C-strings,
any bidirectional iterator type can be searched, allowing for the possibility
of seamlessly searching almost any kind of data.
</P>
<P>For search and replace operations in addition to the algorithm <A href="regex_replace.html">
regex_replace</A> that we have already seen, the algorithm <A href="regex_format.html">
regex_format</A> takes the result of a match and a format string, and
produces a new string by merging the two.</P>
<P>For those that dislike templates, there is a high level wrapper class RegEx
that is an encapsulation of the lower level template code - it provides a
simplified interface for those that don't need the full power of the library,
and supports only narrow characters, and the "extended" regular expression
syntax.
</P>
<P>The <A href="posix_api.html">POSIX API</A> functions: regcomp, regexec, regfree
and regerror, are available in both narrow character and Unicode versions, and
are provided for those who need compatibility with these API's.
</P>
<P>Finally, note that the library now has run-time <A href="localisation.html">localization</A>
support, and recognizes the full POSIX regular expression syntax - including
advanced features like multi-character collating elements and equivalence
classes - as well as providing compatibility with other regular expression
libraries including GNU and BSD4 regex packages, and to a more limited extent
perl 5.
</P>
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

1126
doc/localisation.html Normal file

File diff suppressed because it is too large Load Diff

266
doc/match_flag_type.html Normal file
View File

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

390
doc/match_results.html Normal file
View File

@ -0,0 +1,390 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: class match_results</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">class match_results</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<H3>Contents</H3>
<DL class="index">
<DT><A href="#synopsis">Synopsis</A> <DT><A href="#description">Description</A></DT>
</DL>
<H3><A name="synopsis"></A>Synopsis</H3>
<P>#include &lt;<A href="../../boost/regex.hpp">boost/regex.hpp</A>&gt;
</P>
<P>Regular expressions are different from many simple pattern-matching algorithms
in that as well as finding an overall match they can also produce
sub-expression matches: each sub-expression being delimited in the pattern by a
pair of parenthesis (...). There has to be some method for reporting
sub-expression matches back to the user: this is achieved this by defining a
class <I>match_results</I> that acts as an indexed collection of sub-expression
matches, each sub-expression match being contained in an object of type <I><A href="sub_match.html">
sub_match</A></I>
.
<P>Template class match_results denotes a collection of character sequences
representing the result of a regular expression match. Objects of type
match_results are passed to the algorithms <A href="regex_match.html">regex_match</A>
and <A href="regex_search">regex_search</A>, and are returned by the iterator <A href="regex_iterator.html">
regex_iterator</A>
.&nbsp; Storage for the collection is allocated and freed as necessary by the
member functions of class match_results.
<P>The template class match_results conforms to the requirements of a Sequence, as
specified in (lib.sequence.reqmts), except that only operations defined for
const-qualified Sequences are supported.</P>
<P>Class template match_results is most commonly used as one of the typedefs
cmatch, wcmatch, smatch, or wsmatch:</P>
<PRE>template &lt;class BidirectionalIterator,
class Allocator = allocator&lt;sub_match&lt;BidirectionalIterator&gt; &gt;
class match_results;
typedef match_results&lt;const char*&gt; cmatch;
typedef match_results&lt;const wchar_t*&gt; wcmatch;
typedef match_results&lt;string::const_iterator&gt; smatch;
typedef match_results&lt;wstring::const_iterator&gt; wsmatch;
template &lt;class BidirectionalIterator,
class Allocator = allocator&lt;sub_match&lt;BidirectionalIterator&gt; &gt;
class match_results
{
public:
typedef sub_match&lt;BidirectionalIterator&gt; value_type;
typedef const value_type&amp; const_reference;
typedef const_reference reference;
typedef implementation defined const_iterator;
typedef const_iterator iterator;
typedef typename iterator_traits&lt;BidirectionalIterator&gt;::difference_type difference_type;
typedef typename Allocator::size_type size_type;
typedef Allocator allocator_type;
typedef typename iterator_traits&lt;BidirectionalIterator&gt;::value_type char_type;
typedef basic_string&lt;char_type&gt; string_type;
// construct/copy/destroy:
explicit match_results(const Allocator&amp; a = Allocator());
match_results(const match_results&amp; m);
match_results&amp; operator=(const match_results&amp; m);
~match_results();
// size:
size_type size() const;
size_type max_size() const;
bool empty() const;
// element access:
difference_type length(int sub = 0) const;
difference_type position(unsigned int sub = 0) const;
string_type str(int sub = 0) const;
const_reference operator[](int n) const;
const_reference prefix() const;
const_reference suffix() const;
const_iterator begin() const;
const_iterator end() const;
// format:
template &lt;class OutputIterator&gt;
OutputIterator format(OutputIterator out,
const string_type&amp; fmt,
match_flag_type flags = format_default) const;
string_type format(const string_type&amp; fmt,
match_flag_type flags = format_default) const;
allocator_type get_allocator() const;
void swap(match_results&amp; that);
};
template &lt;class BidirectionalIterator, class Allocator&gt;
bool operator == (const match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m1,
const match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m2);
template &lt;class BidirectionalIterator, class Allocator&gt;
bool operator != (const match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m1,
const match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m2);
template &lt;class charT, class traits, class BidirectionalIterator, class Allocator&gt;
basic_ostream&lt;charT, traits&gt;&amp;
operator &lt;&lt; (basic_ostream&lt;charT, traits&gt;&amp; os,
const match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m);
template &lt;class BidirectionalIterator, class Allocator&gt;
void swap(match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m1,
match_results&lt;BidirectionalIterator, Allocator&gt;&amp; m2);</PRE>
<H3><A name="description"></A>Description</H3>
<H4>match_results constructors</H4>
<P>In all <CODE>match_results</CODE> constructors, a copy of the Allocator
argument is used for any memory allocation performed by the constructor or
member functions during the lifetime of the object.
</P>
<PRE>match_results(const Allocator&amp; a = Allocator());</PRE>
<B>
<P>
Effects:</B> Constructs an object of class match_results. The postconditions
of this function are indicated in Table RE16:</P><I>
<H6 align="center">
Table RE16--</I>match_results(const Allocator&amp;)<I> effects</H6>
<P>
<DIV align="center">
<P></P>
</I>
<P align="center">
<CENTER>
<TABLE id="Table2" cellSpacing="1" cellPadding="7" width="624" border="1">
<TBODY>
<TR>
<TD vAlign="top" width="50%"><B>
<P>
Element</B>
</P>
</TD>
<TD vAlign="top" width="50%"><B>
<P>
Value</B> </P></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>empty()</P>
</TD>
<TD vAlign="top" width="50%">
<P>true</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>size()</P>
</TD>
<TD vAlign="top" width="50%">
<P>0</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>str()</P>
</TD>
<TD vAlign="top" width="50%">
<P>basic_string&lt;charT&gt;()</P>
<P></P>
</TD>
</TR>
</TBODY></TD></TR></TABLE></CENTER>
<P></P>
</DIV><PRE>match_results(const match_results&amp; m);</PRE>
<B>
<P>
Effects:</B> Constructs an object of class match_results, as a copy of
m.</P><PRE>match_results&amp; operator=(const match_results&amp; m);</PRE>
<B>
<P>
Effects:</B> Assigns m to *this. The postconditions of this function are
indicated in Table RE17:</P>
<H6 align="center">Table RE17--match_results(const Allocator&amp;) effects</H6>
<P>
<DIV align="center">
<P></P>
<P align="center">
<CENTER>
<TABLE id="Table3" cellSpacing="1" cellPadding="7" width="624" border="1">
<TBODY>
<TR>
<TD vAlign="top" width="50%"><B>
<P>
Element</B>
</P>
</TD>
<TD vAlign="top" width="50%"><B>
<P>
Value</B>
</P>
</TD></TR>
<TR>
<TD vAlign="top" width="50%">
<P>empty()</P>
</TD>
<TD vAlign="top" width="50%">
<P>m.empty().</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>size()</P>
</TD>
<TD vAlign="top" width="50%">
<P>m.size().</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>str(n)</P>
</TD>
<TD vAlign="top" width="50%">
<P>m.str(n) for all integers n &lt; m.size().</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>prefix()</P>
</TD>
<TD vAlign="top" width="50%">
<P>m.prefix().</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>suffix()</P>
</TD>
<TD vAlign="top" width="50%">
<P>m.suffix().</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>(*this)[n]</P>
</TD>
<TD vAlign="top" width="50%">
<P>m[n] for all integers n &lt; m.size().</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>length(n)</P>
</TD>
<TD vAlign="top" width="50%">
<P>m.length(n) for all integers n &lt; m.size().</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>position(n)</P>
</TD>
<TD vAlign="top" width="50%">
<P>m.position(n) for all integers n &lt; m.size().</P>
<P></P>
</TD>
</TR>
</TBODY></TD></TR></TABLE></CENTER>
<P></P>
</DIV>
<H4>match_results size</H4>
<PRE>size_type size()const;</PRE>
<B>
<P>
Effects:</B> Returns the number of sub_match elements stored in *this.</P><PRE>size_type max_size()const;</PRE>
<B>
<P>
Effects:</B> Returns the maximum number of sub_match elements that can be
stored in *this.</P><PRE>bool empty()const;</PRE>
<B>
<P>
Effects:</B> Returns <CODE>size() == 0</CODE>.</P>
<H4>match_results element access</H4>
<PRE>difference_type length(int sub = 0)const;</PRE>
<B>
<P>
Effects:</B> Returns <CODE>(*this)[sub].length()</CODE>.</P><PRE>difference_type position(unsigned int sub = 0)const;</PRE>
<B>
<P>
Effects:</B> Returns <CODE>std::distance(prefix().first,
(*this)[sub].first).</P></CODE><PRE>string_type str(int sub = 0)const;</PRE>
<B>
<P>
Effects:</B> Returns <CODE>string_type((*this)[sub]).</P></CODE><PRE>const_reference operator[](int n) const;</PRE>
<B>
<P>
Effects:</B> Returns a reference to the <CODE>sub_match </CODE>object
representing the character sequence that matched marked sub-expression <I>n</I>.
If <CODE>n == 0 </CODE>then returns a reference to a <CODE>sub_match</CODE> object
representing the character sequence that matched the whole regular
expression.</P><PRE>const_reference prefix()const;</PRE>
<B>
<P>
Effects:</B> Returns a reference to the <CODE>sub_match </CODE>object
representing the character sequence from the start of the string being
matched/searched, to the start of the match found.</P><PRE>const_reference suffix()const;</PRE>
<B>
<P>
Effects:</B> Returns a reference to the <CODE>sub_match </CODE>object
representing the character sequence from the end of the match found to the end
of the string being matched/searched.</P><PRE>const_iterator begin()const;</PRE>
<B>
<P>
Effects:</B> Returns a starting iterator that enumerates over all the marked
sub-expression matches stored in *this.</P><PRE>const_iterator end()const;</PRE>
<B>
<P>
Effects:</B> Returns a terminating iterator that enumerates over all the
marked sub-expression matches stored in *this.</P>
<H4>match_results reformatting</H4>
<PRE>template &lt;class OutputIterator&gt;
OutputIterator format(OutputIterator out,
const string_type&amp; fmt,
<A href="match_flag_type.html">match_flag_type</A> flags = format_default);</PRE>
<B>
<P>
Requires: </B>The type OutputIterator conforms to the Output Iterator
requirements (24.1.2).</P><B>
<P>
Effects:</B> Copies the character sequence <I>[fmt.begin(), fmt.end())</I> to
OutputIterator <I>out</I>. For each format specifier or escape sequence in <I>fmt</I>,
replace that sequence with either the character(s) it represents, or the
sequence of characters within *this to which it refers. The bitmasks specified
in <I><A href="match_flag_type.html">flags</A></I> determines what <A href="format_syntax.html">
format specifiers or escape sequences are recognized</A>, by default this is
the format used by ECMA-262, ECMAScript Language Specification, Chapter 15 part
5.4.11 String.prototype.replace.</P><B>
<P>
Returns:</B> <I>out</I>.</P><PRE>string_type format(const string_type&amp; fmt,
<A href="match_flag_type.html">match_flag_type</A> flags = format_default);</PRE>
<B>
<P>
Effects:</B> Returns a copy of the string <I>fmt</I>. For each format
specifier or escape sequence in <I>fmt</I>, replace that sequence with either
the character(s) it represents, or the sequence of characters within *this to
which it refers. The bitmasks specified in <I><A href="match_flag_type.html">flags</A></I>
determines what <A href="format_syntax.html">format specifiers or escape sequences
are recognized</A>, by default this is the format used by ECMA-262,
ECMAScript Language Specification, Chapter 15 part 5.4.11
String.prototype.replace.</P><PRE>allocator_type get_allocator()const;</PRE>
<B>
<P>
Effects:</B> Returns a copy of the Allocator that was passed to the object's
constructor.</P><PRE>void swap(match_results&amp; that);</PRE>
<B>
<P>
Effects:</B> Swaps the contents of the two sequences. </P><B>
<P>
Postcondition:</B> <CODE>*this</CODE> contains the sequence of matched
sub-expressions that were in <CODE>that</CODE>, <CODE>that</CODE> contains the
sequence of matched sub-expressions that were in <CODE>*this</CODE>. </P><B>
<P>
Complexity:</B> constant time.
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

184
doc/partial_matches.html Normal file
View File

@ -0,0 +1,184 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Partial Matches</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">Partial Matches</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<P>The <A href="match_flag_type.html">match-flag</A> <CODE>match_partial</CODE> can
be passed to the following algorithms: <A href="regex_match.html">regex_match</A>,
<A href="regex_search.html">regex_search</A>, and <A href="regex_grep.html">regex_grep</A>.
When used it indicates that partial as well as full matches should be found. A
partial match is one that matched one or more characters at the end of the text
input, but did not match all of the regular expression (although it may have
done so had more input been available). Partial matches are typically used when
either validating data input (checking each character as it is entered on the
keyboard), or when searching texts that are either too long to load into memory
(or even into a memory mapped file), or are of indeterminate length (for
example the source may be a socket or similar). Partial and full matches can be
differentiated as shown in the following table (the variable M represents an
instance of <A href="match_results.html">match_results&lt;&gt;</A> as filled in
by regex_match, regex_search or regex_grep):<BR>
</P>
<P>
<TABLE id="Table2" cellSpacing="0" cellPadding="7" width="638" border="0">
<TR>
<TD vAlign="top" width="20%">&nbsp;</TD>
<TD vAlign="top" width="20%">Result</TD>
<TD vAlign="top" width="20%">M[0].matched</TD>
<TD vAlign="top" width="20%">M[0].first</TD>
<TD vAlign="top" width="20%">M[0].second</TD>
</TR>
<TR>
<TD vAlign="top" width="20%">No match</TD>
<TD vAlign="top" width="20%">False</TD>
<TD vAlign="top" width="20%">Undefined</TD>
<TD vAlign="top" width="20%">Undefined</TD>
<TD vAlign="top" width="20%">Undefined</TD>
</TR>
<TR>
<TD vAlign="top" width="20%">Partial match</TD>
<TD vAlign="top" width="20%">True</TD>
<TD vAlign="top" width="20%">False</TD>
<TD vAlign="top" width="20%">Start of partial match.</TD>
<TD vAlign="top" width="20%">End of partial match (end of text).</TD>
</TR>
<TR>
<TD vAlign="top" width="20%">Full match</TD>
<TD vAlign="top" width="20%">True</TD>
<TD vAlign="top" width="20%">True</TD>
<TD vAlign="top" width="20%">Start of full match.</TD>
<TD vAlign="top" width="20%">End of full match.</TD>
</TR>
</TABLE>
</P>
<P>The following <A href="../example/snippets/partial_regex_match.cpp">example</A>
tests to see whether the text could be a valid credit card number, as the user
presses a key, the character entered would be added to the string being built
up, and passed to <CODE>is_possible_card_number</CODE>. If this returns true
then the text could be a valid card number, so the user interface's OK button
would be enabled. If it returns false, then this is not yet a valid card
number, but could be with more input, so the user interface would disable the
OK button. Finally, if the procedure throws an exception the input could never
become a valid number, and the inputted character must be discarded, and a
suitable error indication displayed to the user.</P>
<PRE>#include &lt;string&gt;
#include &lt;iostream&gt;
#include &lt;boost/regex.hpp&gt;
boost::regex e("(\\d{3,4})[- ]?(\\d{4})[- ]?(\\d{4})[- ]?(\\d{4})");
bool is_possible_card_number(const std::string&amp; input)
{
//
// return false for partial match, true for full match, or throw for
// impossible match based on what we have so far...
boost::match_results&lt;std::string::const_iterator&gt; what;
if(0 == boost::regex_match(input, what, e, boost::match_default | boost::match_partial))
{
// the input so far could not possibly be valid so reject it:
throw std::runtime_error("Invalid data entered - this could not possibly be a valid card number");
}
// OK so far so good, but have we finished?
if(what[0].matched)
{
// excellent, we have a result:
return true;
}
// what we have so far is only a partial match...
return false;
}</PRE>
<P>In the following <A href="../example/snippets/partial_regex_match.cpp">example</A>,
text input is taken from a stream containing an unknown amount of text; this
example simply counts the number of html tags encountered in the stream. The
text is loaded into a buffer and searched a part at a time, if a partial match
was encountered, then the partial match gets searched a second time as the
start of the next batch of text:</P>
<PRE>#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;sstream&gt;
#include &lt;string&gt;
#include &lt;boost/regex.hpp&gt;
// match some kind of html tag:
boost::regex e("&lt;[^&gt;]*&gt;");
// count how many:
unsigned int tags = 0;
// saved position of partial match:
char* next_pos = 0;
bool grep_callback(const boost::match_results&lt;char*&gt;&amp; m)
{
if(m[0].matched == false)
{
// save position and return:
next_pos = m[0].first;
}
else
++tags;
return true;
}
void search(std::istream&amp; is)
{
char buf[4096];
next_pos = buf + sizeof(buf);
bool have_more = true;
while(have_more)
{
// how much do we copy forward from last try:
unsigned leftover = (buf + sizeof(buf)) - next_pos;
// and how much is left to fill:
unsigned size = next_pos - buf;
// copy forward whatever we have left:
memcpy(buf, next_pos, leftover);
// fill the rest from the stream:
unsigned read = is.readsome(buf + leftover, size);
// check to see if we've run out of text:
have_more = read == size;
// reset next_pos:
next_pos = buf + sizeof(buf);
// and then grep:
boost::regex_grep(grep_callback,
buf,
buf + read + leftover,
e,
boost::match_default | boost::match_partial);
}
}</PRE>
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

288
doc/posix_api.html Normal file
View File

@ -0,0 +1,288 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: POSIX API Compatibility Functions</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">POSIX API Compatibility Functions</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<PRE>#include &lt;boost/cregex.hpp&gt;
<I>or</I>:
#include &lt;boost/regex.h&gt;</PRE>
<P>The following functions are available for users who need a POSIX compatible C
library, they are available in both Unicode and narrow character versions, the
standard POSIX API names are macros that expand to one version or the other
depending upon whether UNICODE is defined or not.
</P>
<P><B>Important</B>: Note that all the symbols defined here are enclosed inside
namespace <I>boost</I> when used in C++ programs, unless you use #include
&lt;boost/regex.h&gt; instead - in which case the symbols are still defined in
namespace boost, but are made available in the global namespace as well.</P>
<P>The functions are defined as:
</P>
<PRE>extern "C" {
<B>int</B> regcompA(regex_tA*, <B>const</B> <B>char</B>*, <B>int</B>);
<B>unsigned</B> <B>int</B> regerrorA(<B>int</B>, <B>const</B> regex_tA*, <B>char</B>*, <B>unsigned</B> <B>int</B>);
<B>int</B> regexecA(<B>const</B> regex_tA*, <B>const</B> <B>char</B>*, <B>unsigned</B> <B>int</B>, regmatch_t*, <B>int</B>);
<B>void</B> regfreeA(regex_tA*);
<B>int</B> regcompW(regex_tW*, <B>const</B> <B>wchar_t</B>*, <B>int</B>);
<B>unsigned</B> <B>int</B> regerrorW(<B>int</B>, <B>const</B> regex_tW*, <B>wchar_t</B>*, <B>unsigned</B> <B>int</B>);
<B>int</B> regexecW(<B>const</B> regex_tW*, <B>const</B> <B>wchar_t</B>*, <B>unsigned</B> <B>int</B>, regmatch_t*, <B>int</B>);
<B>void</B> regfreeW(regex_tW*);
#ifdef UNICODE
#define regcomp regcompW
#define regerror regerrorW
#define regexec regexecW
#define regfree regfreeW
#define regex_t regex_tW
#else
#define regcomp regcompA
#define regerror regerrorA
#define regexec regexecA
#define regfree regfreeA
#define regex_t regex_tA
#endif
}</PRE>
<P>All the functions operate on structure <B>regex_t</B>, which exposes two public
members:
</P>
<P><B>unsigned int re_nsub</B> this is filled in by <B>regcomp</B> and indicates
the number of sub-expressions contained in the regular expression.
</P>
<P><B>const TCHAR* re_endp</B> points to the end of the expression to compile when
the flag REG_PEND is set.
</P>
<P><I>Footnote: regex_t is actually a #define - it is either regex_tA or regex_tW
depending upon whether UNICODE is defined or not, TCHAR is either char or
wchar_t again depending upon the macro UNICODE.</I>
</P>
<H3>regcomp</H3>
<P><B>regcomp</B> takes a pointer to a <B>regex_t</B>, a pointer to the expression
to compile and a flags parameter which can be a combination of:
<BR>
&nbsp;
</P>
<P>
<TABLE id="Table2" cellSpacing="0" cellPadding="7" width="100%" border="0">
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">REG_EXTENDED</TD>
<TD vAlign="top" width="45%">Compiles modern regular expressions. Equivalent to
regbase::char_classes | regbase::intervals | regbase::bk_refs.</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">REG_BASIC</TD>
<TD vAlign="top" width="45%">Compiles basic (obsolete) regular expression syntax.
Equivalent to regbase::char_classes | regbase::intervals | regbase::limited_ops
| regbase::bk_braces | regbase::bk_parens | regbase::bk_refs.</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">REG_NOSPEC</TD>
<TD vAlign="top" width="45%">All characters are ordinary, the expression is a
literal string.</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">REG_ICASE</TD>
<TD vAlign="top" width="45%">Compiles for matching that ignores character case.</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">REG_NOSUB</TD>
<TD vAlign="top" width="45%">Has no effect in this library.</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">REG_NEWLINE</TD>
<TD vAlign="top" width="45%">When this flag is set a dot does not match the
newline character.</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">REG_PEND</TD>
<TD vAlign="top" width="45%">When this flag is set the re_endp parameter of the
regex_t structure must point to the end of the regular expression to compile.</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">REG_NOCOLLATE</TD>
<TD vAlign="top" width="45%">When this flag is set then locale dependent collation
for character ranges is turned off.</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">REG_ESCAPE_IN_LISTS<BR>
, , ,
</TD>
<TD vAlign="top" width="45%">When this flag is set, then escape sequences are
permitted in bracket expressions (character sets).</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">REG_NEWLINE_ALT&nbsp;</TD>
<TD vAlign="top" width="45%">When this flag is set then the newline character is
equivalent to the alternation operator |.</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">REG_PERL&nbsp;</TD>
<TD vAlign="top" width="45%">&nbsp;A shortcut for perl-like behavior: REG_EXTENDED
| REG_NOCOLLATE | REG_ESCAPE_IN_LISTS</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">REG_AWK</TD>
<TD vAlign="top" width="45%">A shortcut for awk-like behavior: REG_EXTENDED |
REG_ESCAPE_IN_LISTS</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">REG_GREP</TD>
<TD vAlign="top" width="45%">A shortcut for grep like behavior: REG_BASIC |
REG_NEWLINE_ALT</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">REG_EGREP</TD>
<TD vAlign="top" width="45%">&nbsp;A shortcut for egrep like behavior:
REG_EXTENDED | REG_NEWLINE_ALT</TD>
<TD width="5%">&nbsp;</TD>
</TR>
</TABLE>
</P>
<H3>regerror</H3>
<P>regerror takes the following parameters, it maps an error code to a human
readable string:
<BR>
</P>
<P>
<TABLE id="Table3" cellSpacing="0" cellPadding="7" width="100%" border="0">
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="50%">int code</TD>
<TD vAlign="top" width="50%">The error code.</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">const regex_t* e</TD>
<TD vAlign="top" width="50%">The regular expression (can be null).</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">char* buf</TD>
<TD vAlign="top" width="50%">The buffer to fill in with the error message.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">unsigned int buf_size</TD>
<TD vAlign="top" width="50%">The length of buf.</TD>
<TD>&nbsp;</TD>
</TR>
</TABLE>
</P>
<P>If the error code is OR'ed with REG_ITOA then the message that results is the
printable name of the code rather than a message, for example "REG_BADPAT". If
the code is REG_ATIO then <B>e</B> must not be null and <B>e-&gt;re_pend</B> must
point to the printable name of an error code, the return value is then the
value of the error code. For any other value of <B>code</B>, the return value
is the number of characters in the error message, if the return value is
greater than or equal to <B>buf_size</B> then <B>regerror</B> will have to be
called again with a larger buffer.</P>
<H3>regexec</H3>
<P><B>regexec</B> finds the first occurrence of expression <B>e</B> within string <B>buf</B>.
If <B>len</B> is non-zero then *<B>m</B> is filled in with what matched the
regular expression, <B>m[0]</B> contains what matched the whole string, <B>m[1] </B>
the first sub-expression etc, see <B>regmatch_t</B> in the header file
declaration for more details. The <B>eflags</B> parameter can be a combination
of:
<BR>
&nbsp;
</P>
<P>
<TABLE id="Table4" cellSpacing="0" cellPadding="7" width="100%" border="0">
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="50%">REG_NOTBOL</TD>
<TD vAlign="top" width="50%">Parameter <B>buf </B>does not represent the start of
a line.</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">REG_NOTEOL</TD>
<TD vAlign="top" width="50%">Parameter <B>buf</B> does not terminate at the end of
a line.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">REG_STARTEND</TD>
<TD vAlign="top" width="50%">The string searched starts at buf + pmatch[0].rm_so
and ends at buf + pmatch[0].rm_eo.</TD>
<TD>&nbsp;</TD>
</TR>
</TABLE>
</P>
<H3>regfree</H3>
<P>Finally <B>regfree</B> frees all the memory that was allocated by regcomp.
</P>
<P><I>Footnote: this is an abridged reference to the POSIX API functions, it is
provided for compatibility with other libraries, rather than an API to be used
in new code (unless you need access from a language other than C++). This
version of these functions should also happily coexist with other versions, as
the names used are macros that expand to the actual function names.</I>
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

83
doc/redistributables.html Normal file
View File

@ -0,0 +1,83 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Redistributables and Library Names</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">Redistributables and Library Names</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<P>If you are using Microsoft or Borland C++ and link to a dll version of the run
time library, then you will also link to one of the dll versions of boost.regex.
While these dll's are redistributable, there are no "standard" versions, so
when installing on the users PC, you should place these in a directory private
to your application, and not in the PC's directory path. Note that if you link
to a static version of your run time library, then you will also link to a
static version of boost.regex and no dll's will need to be distributed. The
possible boost.regex dll and library names are computed according to the following
formula:<BR>
</P>
<P></P>
<P>"boost_regex_"<BR>
+ BOOST_LIB_TOOLSET<BR>
+ "_"<BR>
+ BOOST_LIB_THREAD_OPT<BR>
+ BOOST_LIB_RT_OPT<BR>
+ BOOST_LIB_LINK_OPT<BR>
+ BOOST_LIB_DEBUG_OPT<BR>
<BR>
These are defined as:<BR>
<BR>
BOOST_LIB_TOOLSET: The compiler toolset name (vc6, vc7, bcb5 etc).<BR>
<BR>
BOOST_LIB_THREAD_OPT: "s" for single thread builds,<BR>
"m" for multithread builds.<BR>
<BR>
BOOST_LIB_RT_OPT: "s" for static runtime,<BR>
"d" for dynamic runtime.<BR>
<BR>
BOOST_LIB_LINK_OPT: "s" for static link,<BR>
"i" for dynamic link.<BR>
<BR>
BOOST_LIB_DEBUG_OPT: nothing for release builds,<BR>
"d" for debug builds,<BR>
"dd" for debug-diagnostic builds (_STLP_DEBUG).</P>
<P>
Note: you can disable automatic library selection by defining the symbol
BOOST_REGEX_NO_LIB when compiling, this is useful if you want to statically
link even though you're using the dll version of your run time library, or if
you need to debug boost.regex.
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

45
doc/reg_expression.html Normal file
View File

@ -0,0 +1,45 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Class reg_expression (deprecated)</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">Class reg_expression (deprecated)</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<P>The use of class template reg_expression is deprecated: use <A href="basic_regex.html">
basic_regex</A> instead.</P>
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

55
doc/regbase.html Normal file
View File

@ -0,0 +1,55 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: regbase</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">regbase</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<P>Use of the type <code>boost::regbase</code> is now deprecated, and the type does not form a
part of the <A href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1429.htm">
regular expression standardization proposal</A>.&nbsp; This type still
exists as a base class of <code>boost::basic_regex</code>, and you can still refer to
<code>boost::regbase::constant_name</code> in your code, however for maximum portability to
other std regex implementations you should instead use either:</P>
<PRE>boost::regex_constants::constant_name</PRE>
<P>or</P>
<PRE>boost::regex::constant_name</PRE>
<P>or</P>
<PRE>boost::wregex::constant_name</PRE>
<P>
<HR>
</P>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

492
doc/regex.html Normal file
View File

@ -0,0 +1,492 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: class RegEx (deprecated)</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">class RegEx (deprecated)</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<P>The high level wrapper class RegEx is now deprecated and does not form a part
of the <A href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1429.htm">regular
expression standardization proposal</A>.&nbsp; This type still exists, and
existing code will continue to compile, however the following documentation is
unlikely to be further updated.</P>
<PRE>#include &lt;boost/cregex.hpp&gt; </PRE>
<P>The class RegEx provides a high level simplified interface to the regular
expression library, this class only handles narrow character strings, and
regular expressions always follow the "normal" syntax - that is the same as the
perl / ECMAScript synatx.
</P>
<PRE><B>typedef</B> <B>bool</B> (*GrepCallback)(<B>const</B> RegEx&amp; expression);
<B>typedef</B> <B>bool</B> (*GrepFileCallback)(<B>const</B> <B>char</B>* file, <B>const</B> RegEx&amp; expression);
<B>typedef</B> <B>bool</B> (*FindFilesCallback)(<B>const</B> <B>char</B>* file);
<B>class</B>&nbsp; RegEx
{
<B>public</B>:
&nbsp;&nbsp; RegEx();
&nbsp;&nbsp; RegEx(<B>const</B> RegEx&amp; o);
&nbsp;&nbsp; ~RegEx();
&nbsp;&nbsp; RegEx(<B>const</B> <B>char</B>* c, <B>bool</B> icase = <B>false</B>);
&nbsp;&nbsp; <STRONG>explicit</STRONG> RegEx(<B>const</B> std::string&amp; s, <B>bool</B> icase = <B>false</B>);
&nbsp;&nbsp; RegEx&amp; <B>operator</B>=(<B>const</B> RegEx&amp; o);
&nbsp;&nbsp; RegEx&amp; <B>operator</B>=(<B>const</B> <B>char</B>* p);
&nbsp;&nbsp; RegEx&amp; <B>operator</B>=(<B>const</B> std::string&amp; s);
&nbsp;&nbsp; <B>unsigned</B> <B>int</B> SetExpression(<B>const</B> <B>char</B>* p, <B>bool</B> icase = <B>false</B>);
&nbsp;&nbsp; <B>unsigned</B> <B>int</B> SetExpression(<B>const</B> std::string&amp; s, <B>bool</B> icase = <B>false</B>);
&nbsp;&nbsp; std::string Expression()<B>const</B>;
&nbsp;&nbsp; <FONT color=#000080><I>//
</I>&nbsp;&nbsp;<I>// now matching operators: </I>
&nbsp;&nbsp; <I>// </I></FONT>
&nbsp;&nbsp; <B>bool</B> Match(<B>const</B> <B>char</B>* p, <B>unsigned</B> <B>int</B> flags = match_default);
&nbsp;&nbsp; <B>bool</B> Match(<B>const</B> std::string&amp; s, <B>unsigned</B> <B>int</B> flags = match_default);
&nbsp;&nbsp; <B>bool</B> Search(<B>const</B> <B>char</B>* p, <B>unsigned</B> <B>int</B> flags = match_default);
&nbsp;&nbsp; <B>bool</B> Search(<B>const</B> std::string&amp; s, <B>unsigned</B> <B>int</B> flags = match_default);
&nbsp;&nbsp; <B>unsigned</B> <B>int</B> Grep(GrepCallback cb, <B>const</B> <B>char</B>* p, <B>unsigned</B> <B>int</B> flags = match_default);
&nbsp;&nbsp; <B>unsigned</B> <B>int</B> Grep(GrepCallback cb, <B>const</B> std::string&amp; s, <B>unsigned</B> <B>int</B> flags = match_default);
&nbsp;&nbsp; <B>unsigned</B> <B>int</B> Grep(std::vector&lt;std::string&gt;&amp; v, <B>const</B> <B>char</B>* p, <B>unsigned</B> <B>int</B> flags = match_default);
&nbsp;&nbsp; <B>unsigned</B> <B>int</B> Grep(std::vector&lt;std::string&gt;&amp; v, <B>const</B> std::string&amp; s, <B>unsigned</B> <B>int</B> flags = match_default);
&nbsp;&nbsp; <B>unsigned</B> <B>int</B> Grep(std::vector&lt;<B>unsigned</B> <B>int</B>&gt;&amp; v, <B>const</B> <B>char</B>* p, <B>unsigned</B> <B>int</B> flags = match_default);
&nbsp;&nbsp; <B>unsigned</B> <B>int</B> Grep(std::vector&lt;<B>unsigned</B> <B>int</B>&gt;&amp; v, <B>const</B> std::string&amp; s, <B>unsigned</B> <B>int</B> flags = match_default);
&nbsp;&nbsp; <B>unsigned</B> <B>int</B> GrepFiles(GrepFileCallback cb, <B>const</B> <B>char</B>* files, <B>bool</B> recurse = <B>false</B>, <B>unsigned</B> <B>int</B> flags = match_default);
&nbsp;&nbsp; <B>unsigned</B> <B>int</B> GrepFiles(GrepFileCallback cb, <B>const</B> std::string&amp; files, <B>bool</B> recurse = <B>false</B>, <B>unsigned</B> <B>int</B> flags = match_default);
&nbsp;&nbsp; <B>unsigned</B> <B>int</B> FindFiles(FindFilesCallback cb, <B>const</B> <B>char</B>* files, <B>bool</B> recurse = <B>false</B>, <B>unsigned</B> <B>int</B> flags = match_default);
&nbsp;&nbsp; <B>unsigned</B> <B>int</B> FindFiles(FindFilesCallback cb, <B>const</B> std::string&amp; files, <B>bool</B> recurse = <B>false</B>, <B>unsigned</B> <B>int</B> flags = match_default);
&nbsp;&nbsp; std::string Merge(<B>const</B> std::string&amp; in, <B>const</B> std::string&amp; fmt, <B>bool</B> copy = <B>true</B>, <B>unsigned</B> <B>int</B> flags = match_default);
&nbsp;&nbsp; std::string Merge(<B>const</B> char* in, <B>const</B> char* fmt, <B>bool</B> copy = <B>true</B>, <B>unsigned int </B>flags = match_default);
&nbsp;&nbsp; <B>unsigned</B> Split(std::vector&lt;std::string&gt;&amp; v, std::string&amp; s, <B>unsigned</B> flags = match_default, <B>unsigned</B> max_count = ~0);
&nbsp;&nbsp; <FONT color=#000080><I>//
</I>&nbsp;&nbsp; <I>// now operators for returning what matched in more detail:
</I>&nbsp;&nbsp; <I>//
</I></FONT>&nbsp;&nbsp; <B>unsigned</B> <B>int</B> Position(<B>int</B> i = 0)<B>const</B>;
&nbsp;&nbsp; <B>unsigned</B> <B>int</B> Length(<B>int</B> i = 0)<B>const</B>;
<STRONG>bool</STRONG> Matched(<STRONG>int</STRONG> i = 0)<STRONG>const</STRONG>;
&nbsp;&nbsp; <B>unsigned</B> <B>int</B> Line()<B>const</B>;
&nbsp;&nbsp; <B>unsigned int</B> Marks() const;
&nbsp;&nbsp; std::string What(<B>int</B> i)<B>const</B>;
&nbsp;&nbsp; std::string <B>operator</B>[](<B>int</B> i)<B>const</B> ;
<STRONG>static const unsigned int</STRONG> npos;
}; &nbsp; &nbsp; </PRE>
<P>Member functions for class RegEx are defined as follows:
<BR>
&nbsp;
</P>
<P>
<TABLE id="Table2" cellSpacing="0" cellPadding="7" width="100%" border="0">
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%">RegEx();</TD>
<TD vAlign="top" width="42%">Default constructor, constructs an instance of RegEx
without any valid expression.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%">RegEx(<B>const</B> RegEx&amp; o);</TD>
<TD vAlign="top" width="42%">Copy constructor, all the properties of parameter <I>o</I>
are copied.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%">RegEx(<B>const</B> <B>char</B>* c, <B>bool</B> icase
= <B>false</B>);</TD>
<TD vAlign="top" width="42%">Constructs an instance of RegEx, setting the
expression to <I>c</I>, if <I>icase</I> is <I>true</I> then matching is
insensitive to case, otherwise it is sensitive to case. Throws <I>bad_expression</I>
on failure.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%">RegEx(<B>const</B> std::string&amp; s, <B>bool</B> icase
= <B>false</B>);</TD>
<TD vAlign="top" width="42%">Constructs an instance of RegEx, setting the
expression to <I>s</I>, if <I>icase </I>is <I>true</I> then matching is
insensitive to case, otherwise it is sensitive to case. Throws <I>bad_expression</I>
on failure.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%">RegEx&amp; <B>operator</B>=(<B>const</B> RegEx&amp;
o);</TD>
<TD vAlign="top" width="42%">Default assignment operator.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%">RegEx&amp; <B>operator</B>=(<B>const</B> <B>char</B>*
p);</TD>
<TD vAlign="top" width="42%">Assignment operator, equivalent to calling <I>SetExpression(p,
false).</I> Throws <I>bad_expression</I> on failure.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%">RegEx&amp; <B>operator</B>=(<B>const</B> std::string&amp;
s);</TD>
<TD vAlign="top" width="42%">Assignment operator, equivalent to calling <I>SetExpression(s,
false).</I> Throws <I>bad_expression</I> on failure.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>unsigned</B> <B>int</B> SetExpression(<B>constchar</B>*
p, <B>bool</B> icase = <B>false</B>);</TD>
<TD vAlign="top" width="42%">Sets the current expression to <I>p</I>, if <I>icase</I>
is <I>true</I> then matching is insensitive to case, otherwise it is sensitive
to case. Throws <I>bad_expression</I> on failure.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>unsigned</B> <B>int</B> SetExpression(<B>const</B>
std::string&amp; s, <B>bool</B> icase = <B>false</B>);</TD>
<TD vAlign="top" width="42%">Sets the current expression to <I>s</I>, if <I>icase</I>
is <I>true</I> then matching is insensitive to case, otherwise it is sensitive
to case. Throws <I>bad_expression</I> on failure.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%">std::string Expression()<B>const</B>;</TD>
<TD vAlign="top" width="42%">Returns a copy of the current regular expression.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>bool</B> Match(<B>const</B> <B>char</B>* p, <B>unsigned</B>
<B>int</B> flags = match_default);</TD>
<TD vAlign="top" width="42%">Attempts to match the current expression against the
text <I>p</I> using the match flags <I>flags</I> - see <A href="match_flag_type.html">
match flags</A>. Returns <I>true</I> if the expression matches the whole of
the input string.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>bool</B> Match(<B>const</B> std::string&amp; s, <B>unsigned</B>
<B>int</B> flags = match_default) ;</TD>
<TD vAlign="top" width="42%">Attempts to match the current expression against the
text <I>s</I> using the match flags <I>flags</I> - see <A href="match_flag_type.html">
match flags</A>. Returns <I>true</I> if the expression matches the whole of
the input string.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>bool</B> Search(<B>const</B> <B>char</B>* p, <B>unsigned</B>
<B>int</B> flags = match_default);</TD>
<TD vAlign="top" width="42%">Attempts to find a match for the current expression
somewhere in the text <I>p</I> using the match flags <I>flags </I>- see <A href="match_flag_type.html">
match flags</A>. Returns <I>true</I> if the match succeeds.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>bool</B> Search(<B>const</B> std::string&amp; s, <B>unsigned</B>
<B>int</B> flags = match_default) ;</TD>
<TD vAlign="top" width="42%">Attempts to find a match for the current expression
somewhere in the text <I>s</I> using the match flags <I>flags </I>- see <A href="match_flag_type.html">
match flags</A>. Returns <I>true</I> if the match succeeds.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>unsigned</B> <B>int</B> Grep(GrepCallback cb, <B>const</B>
<B>char</B>* p, <B>unsigned</B> <B>int</B> flags = match_default);</TD>
<TD vAlign="top" width="42%">Finds all matches of the current expression in the
text <I>p</I> using the match flags <I>flags </I>- see <A href="match_flag_type.html">
match flags</A>. For each match found calls the call-back function <I>cb</I>
as: cb(*this);
<P>If at any stage the call-back function returns false then the grep operation
terminates, otherwise continues until no further matches are found. Returns the
number of matches found.</P>
</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>unsigned</B> <B>int</B> Grep(GrepCallback cb, <B>const</B>
std::string&amp; s, <B>unsigned</B> <B>int</B> flags = match_default);</TD>
<TD vAlign="top" width="42%">Finds all matches of the current expression in the
text <I>s</I> using the match flags <I>flags </I>- see <A href="match_flag_type.html">
match flags</A>. For each match found calls the call-back function <I>cb</I>
as: cb(*this);
<P>If at any stage the call-back function returns false then the grep operation
terminates, otherwise continues until no further matches are found. Returns the
number of matches found.
</P>
</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>unsigned</B> <B>int</B> Grep(std::vector&lt;std::string&gt;&amp;
v, <B>const</B> <B>char</B>* p, <B>unsigned</B> <B>int</B> flags =
match_default);</TD>
<TD vAlign="top" width="42%">Finds all matches of the current expression in the
text <I>p</I> using the match flags <I>flags </I>- see <A href="match_flag_type.html">
match flags</A>. For each match pushes a copy of what matched onto <I>v</I>.
Returns the number of matches found.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>unsigned</B> <B>int</B> Grep(std::vector&lt;std::string&gt;&amp;
v, <B>const</B> std::string&amp; s, <B>unsigned</B> <B>int</B> flags =
match_default);</TD>
<TD vAlign="top" width="42%">Finds all matches of the current expression in the
text <I>s</I> using the match flags <I>flags </I>- see <A href="match_flag_type.html">
match flags</A>. For each match pushes a copy of what matched onto <I>v</I>.
Returns the number of matches found.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>unsigned</B> <B>int</B> Grep(std::vector&lt;<B>unsigned
int</B>&gt;&amp; v, <B>const</B> <B>char</B>* p, <B>unsigned</B> <B>int</B> flags
= match_default);</TD>
<TD vAlign="top" width="42%">Finds all matches of the current expression in the
text <I>p</I> using the match flags <I>flags </I>- see <A href="match_flag_type.html">
match flags</A>. For each match pushes the starting index of what matched
onto <I>v</I>. Returns the number of matches found.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>unsigned</B> <B>int</B> Grep(std::vector&lt;<B>unsigned
int</B>&gt;&amp; v, <B>const</B> std::string&amp; s, <B>unsigned</B> <B>int</B>
flags = match_default);</TD>
<TD vAlign="top" width="42%">Finds all matches of the current expression in the
text <I>s</I> using the match flags <I>flags </I>- see <A href="match_flag_type.html">
match flags</A>. For each match pushes the starting index of what matched
onto <I>v</I>. Returns the number of matches found.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>unsigned</B> <B>int</B> GrepFiles(GrepFileCallback
cb, <B>const</B> <B>char</B>* files, <B>bool</B> recurse = <B>false</B>, <B>unsigned</B>
<B>int</B> flags = match_default);</TD>
<TD vAlign="top" width="42%">Finds all matches of the current expression in the
files <I>files</I> using the match flags <I>flags </I>- see <A href="match_flag_type.html">
match flags</A>. For each match calls the call-back function cb.&nbsp;
<P>If the call-back returns false then the algorithm returns without considering
further matches in the current file, or any further files.&nbsp;
</P>
<P>The parameter <I>files</I> can include wild card characters '*' and '?', if the
parameter <I>recurse</I> is true then searches sub-directories for matching
file names.&nbsp;
</P>
<P>Returns the total number of matches found.</P>
<P>May throw an exception derived from std::runtime_error if file io fails.</P>
</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>unsigned</B> <B>int</B> GrepFiles(GrepFileCallback
cb, <B>const</B> std::string&amp; files, <B>bool</B> recurse = <B>false</B>, <B>unsigned</B>
<B>int</B> flags = match_default);</TD>
<TD vAlign="top" width="42%">Finds all matches of the current expression in the
files <I>files</I> using the match flags <I>flags </I>- see <A href="match_flag_type.html">
match flags</A>. For each match calls the call-back function cb.&nbsp;
<P>If the call-back returns false then the algorithm returns without considering
further matches in the current file, or any further files.&nbsp;
</P>
<P>The parameter <I>files</I> can include wild card characters '*' and '?', if the
parameter <I>recurse</I> is true then searches sub-directories for matching
file names.&nbsp;
</P>
<P>Returns the total number of matches found.</P>
<P>May throw an exception derived from std::runtime_error if file io fails.</P>
</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>unsigned</B> <B>int</B> FindFiles(FindFilesCallback
cb, <B>const</B> <B>char</B>* files, <B>bool</B> recurse = <B>false</B>, <B>unsigned</B>
<B>int</B> flags = match_default);</TD>
<TD vAlign="top" width="42%">Searches <I>files</I> to find all those which contain
at least one match of the current expression using the match flags <I>flags </I>
- see <A href="match_flag_type.html">match flags</A>. For each
matching file calls the call-back function cb.&nbsp;
<P>If the call-back returns false then the algorithm returns without considering
any further files.&nbsp;
</P>
<P>The parameter <I>files</I> can include wild card characters '*' and '?', if the
parameter <I>recurse</I> is true then searches sub-directories for matching
file names.&nbsp;
</P>
<P>Returns the total number of files found.</P>
<P>May throw an exception derived from std::runtime_error if file io fails.</P>
</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>unsigned</B> <B>int</B> FindFiles(FindFilesCallback
cb, <B>const</B> std::string&amp; files, <B>bool</B> recurse = <B>false</B>, <B>unsigned</B>
<B>int</B> flags = match_default);</TD>
<TD vAlign="top" width="42%">Searches <I>files</I> to find all those which contain
at least one match of the current expression using the match flags <I>flags </I>
- see <A href="match_flag_type.html">match flags</A>. For each
matching file calls the call-back function cb.&nbsp;
<P>If the call-back returns false then the algorithm returns without considering
any further files.&nbsp;
</P>
<P>The parameter <I>files</I> can include wild card characters '*' and '?', if the
parameter <I>recurse</I> is true then searches sub-directories for matching
file names.&nbsp;
</P>
<P>Returns the total number of files found.</P>
<P>May throw an exception derived from std::runtime_error if file io fails.</P>
</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%">std::string Merge(<B>const</B> std::string&amp; in, <B>const</B>
std::string&amp; fmt, <B>bool</B> copy = <B>true</B>, <B>unsigned</B> <B>int</B>
flags = match_default);</TD>
<TD vAlign="top" width="42%">Performs a search and replace operation: searches
through the string <I>in</I> for all occurrences of the current expression, for
each occurrence replaces the match with the format string <I>fmt</I>. Uses <I>flags</I>
to determine what gets matched, and how the format string should be treated. If <I>
copy</I> is true then all unmatched sections of input are copied unchanged
to output, if the flag <EM>format_first_only</EM> is set then only the first
occurance of the pattern found is replaced. Returns the new string. See <A href="format_synatx.html">
also format string syntax</A>, <A href="match_flag_type.html">match
flags</A> and <A href="match_flag_type.html">format flags</A>.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%">std::string Merge(<B>const</B> char* in, <B>const</B>
char* fmt, <B>bool</B> copy = <B>true</B>, <B>unsigned int </B>flags =
match_default);</TD>
<TD vAlign="top" width="42%">Performs a search and replace operation: searches
through the string <I>in</I> for all occurrences of the current expression, for
each occurrence replaces the match with the format string <I>fmt</I>. Uses <I>flags</I>
to determine what gets matched, and how the format string should be treated. If <I>
copy</I> is true then all unmatched sections of input are copied unchanged
to output, if the flag <EM>format_first_only</EM> is set then only the first
occurance of the pattern found is replaced. Returns the new string. See <A href="format_synatx.html">
also format string syntax</A>, <A href="match_flag_type.html">match
flags</A> and <A href="match_flag_type.html">format flags</A>.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top"><B>unsigned</B> Split(std::vector&lt;std::string&gt;&amp; v,
std::string&amp; s, <B>unsigned</B> flags = match_default, <B>unsigned</B> max_count
= ~0);</TD>
<TD vAlign="top">Splits the input string and pushes each one onto the vector. If
the expression contains no marked sub-expressions, then one string is outputted
for each section of the input that does not match the expression. If the
expression does contain marked sub-expressions, then outputs one string for
each marked sub-expression each time a match occurs. Outputs no more than <I>max_count
</I>strings. Before returning, deletes from the input string <I>s</I> all of
the input that has been processed (all of the string if <I>max_count</I> was
not reached). Returns the number of strings pushed onto the vector.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>unsigned</B> <B>int</B> Position(<B>int</B> i = 0)<B>const</B>;</TD>
<TD vAlign="top" width="42%">Returns the position of what matched sub-expression <I>i</I>.
If <I>i = 0</I> then returns the position of the whole match. Returns
RegEx::npos if the supplied index is invalid, or if the specified
sub-expression did not participate in the match.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>unsigned</B> <B>int</B> Length(<B>int</B> i = 0)<B>const</B>;</TD>
<TD vAlign="top" width="42%">Returns the length of what matched sub-expression <I>i</I>.
If <I>i = 0</I> then returns the length of the whole match. Returns RegEx::npos
if the supplied index is invalid, or if the specified sub-expression did not
participate in the match.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD><STRONG>bool</STRONG> Matched(<STRONG>int</STRONG> i = 0)<STRONG>const</STRONG>;</TD>
<TD>Returns true if sub-expression <EM>i</EM> was matched, false otherwise.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>unsigned</B> <B>int</B> Line()<B>const</B>;</TD>
<TD vAlign="top" width="42%">Returns the line on which the match occurred, indexes
start from 1 not zero, if no match occurred then returns RegEx::npos.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%"><B>unsigned int</B> Marks() const;</TD>
<TD vAlign="top" width="42%">Returns the number of marked sub-expressions
contained in the expression. Note that this includes the whole match
(sub-expression zero), so the value returned is always &gt;= 1.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%">std::string What(<B>int</B> i)<B>const</B>;</TD>
<TD vAlign="top" width="42%">Returns a copy of what matched sub-expression <I>i</I>.
If <I>i = 0</I> then returns a copy of the whole match. Returns a null string
if the index is invalid or if the specified sub-expression did not participate
in a match.</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
<TR>
<TD vAlign="top" width="7%">&nbsp;</TD>
<TD vAlign="top" width="43%">std::string <B>operator</B>[](<B>int</B> i)<B>const</B>
;</TD>
<TD vAlign="top" width="42%">Returns <I>what(i);</I>
<P>Can be used to simplify access to sub-expression matches, and make usage more
perl-like.</P>
</TD>
<TD vAlign="top" width="7%">&nbsp;</TD>
</TR>
</TABLE>
</P>
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

165
doc/regex_format.html Normal file
View File

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

379
doc/regex_grep.html Normal file
View File

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

325
doc/regex_match.html Normal file
View File

@ -0,0 +1,325 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Algorithm regex_match</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">Algorithm regex_match</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<H3>Contents</H3>
<dl class="index">
<dt><a href="#synopsis">Synopsis</a></dt>
<dt><a href="#description">Description</a></dt>
<dt><a href="#examples">Examples</a></dt>
</dl>
<H3><A name="synopsis"></A>Synopsis</H3>
<PRE><A name=query_match></A>#include &lt;<A href="../../boost/regex.hpp">boost/regex.hpp</A>&gt; </PRE>
<P>The algorithm regex _match determines whether a given regular expression
matches a given sequence denoted by a pair of bidirectional-iterators, the
algorithm is defined as follows, <EM><FONT color="red">note that the result is true
only if the expression matches the whole of the input sequence</FONT></EM>,
the main use of this function is data input validation.
<PRE>template &lt;class BidirectionalIterator, class Allocator, class charT,
class traits, class Allocator2&gt;
bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
<A href="match_results.html">match_results</A>&lt;BidirectionalIterator, Allocator&gt;&amp; m,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</A> flags = match_default);
template &lt;class BidirectionalIterator, class charT, class traits, class Allocator2&gt;
bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</a> flags = match_default);
template &lt;class charT, class Allocator, class traits, class Allocator2&gt;
bool regex_match(const charT* str, <A href="match_results.html">match_results</A>&lt;const charT*, Allocator&gt;&amp; m,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</A> flags = match_default);
template &lt;class ST, class SA, class Allocator, class charT,
class traits, class Allocator2&gt;
bool regex_match(const basic_string&lt;charT, ST, SA&gt;&amp; s,
<A href="match_results.html">match_results</A>&lt;typename basic_string&lt;charT, ST, SA&gt;::const_iterator, Allocator&gt;&amp; m,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</A> flags = match_default);
template &lt;class charT, class traits, class Allocator2&gt;
bool regex_match(const charT* str,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</A> flags = match_default);
template &lt;class ST, class SA, class charT, class traits, class Allocator2&gt;
bool regex_match(const basic_string&lt;charT, ST, SA&gt;&amp; s,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</A> flags = match_default);
</PRE>
<H3><A name="description"></A>Description</H3>
<PRE>template &lt;class BidirectionalIterator, class Allocator, class charT,
class traits, class Allocator2&gt;
bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
<A href="match_results.html">match_results</A>&lt;BidirectionalIterator, Allocator&gt;&amp; m,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</A> flags = match_default);</PRE>
<B>
<P>
Requires:</B> Type BidirectionalIterator meets the requirements of a
Bidirectional Iterator (24.1.4).</P>
<B>
<P>
Effects: </B>Determines whether there is an exact match between the regular
expression <I>e</I>, and all of the character sequence [first, last), parameter <I>
flags</I> is used to <A href="match_flag_type.html">control how the expression
is matched</A> against the character sequence. Returns true if such a match
exists, false otherwise.</P><B>
<P>
Postconditions: </B>If the function returns false, then the effect on
parameter <I>m</I> is undefined, otherwise the effects on parameter <I>m</I> are
given in the table:</P> <I>
<P>
<DIV align="center">
<P></P>
</I>
<P align="center">
<CENTER>
<TABLE id="Table2" cellSpacing="1" cellPadding="7" width="624" border="1">
<TBODY>
<TR>
<TD vAlign="top" width="50%"><B>
<P>
Element</B>
</P>
</TD>
<TD vAlign="top" width="50%"><B>
<P>
Value</B> </P></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.size()</P>
</TD>
<TD vAlign="top" width="50%">
<P>e.mark_count()</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.empty()</P>
</TD>
<TD vAlign="top" width="50%">
<P>false</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.prefix().first</P>
</TD>
<TD vAlign="top" width="50%">
<P>first</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.prefix().last</P>
</TD>
<TD vAlign="top" width="50%">
<P>first</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.prefix().matched</P>
</TD>
<TD vAlign="top" width="50%">
<P>false</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.suffix().first</P>
</TD>
<TD vAlign="top" width="50%">
<P>last</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.suffix().last</P>
</TD>
<TD vAlign="top" width="50%">
<P>last</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.suffix().matched</P>
</TD>
<TD vAlign="top" width="50%">
<P>false</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[0].first</P>
</TD>
<TD vAlign="top" width="50%">
<P>first</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[0].second</P>
</TD>
<TD vAlign="top" width="50%">
<P>last</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[0].matched</P>
</TD>
<TD vAlign="top" width="50%"><CODE>
<P>
true</CODE> if a full match was found, and <CODE>false</CODE> if it was a
partial match (found as a result of the <CODE>match_partial</CODE> flag being
set).</P></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[n].first</P>
</TD>
<TD vAlign="top" width="50%">
<P>For all integers n &lt; m.size(), the start of the sequence that matched
sub-expression <I>n</I>. Alternatively, if sub-expression n did not participate
in the match, then <I>last</I>.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[n].second</P>
</TD>
<TD vAlign="top" width="50%">
<P>For all integers n &lt; m.size(), the end of the sequence that matched
sub-expression <I>n</I>. Alternatively, if sub-expression n did not participate
in the match, then <I>last</I>.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[n].matched</P>
</TD>
<TD vAlign="top" width="50%">
<P>For all integers n &lt; m.size(), true if sub-expression <I>n</I> participated
in the match, false otherwise.</P>
<P></P>
</TD>
</TR>
</TBODY></TD></TR></TABLE></CENTER>
<P></P>
</DIV><PRE>template &lt;class BidirectionalIterator, class charT, class traits, class Allocator2&gt;
bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</A> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Behaves "as if" by constructing an instance of <CODE><A href="match_results.html">
match_results</A>&lt;</CODE>BidirectionalIterator<CODE>&gt; what</CODE>,
and then returning the result of <CODE>regex_match(first, last, what, e, flags)</CODE>.</P><PRE>template &lt;class charT, class Allocator, class traits, class Allocator2&gt;
bool regex_match(const charT* str, <A href="match_results.html">match_results</A>&lt;const charT*, Allocator&gt;&amp; m,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</A> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>regex_match(str, str +
char_traits&lt;charT&gt;::length(str), m, e, flags)</CODE>.</P><PRE>template &lt;class ST, class SA, class Allocator, class charT,
class traits, class Allocator2&gt;
bool regex_match(const basic_string&lt;charT, ST, SA&gt;&amp; s,
<A href="match_results.html">match_results</A>&lt;typename basic_string&lt;charT, ST, SA&gt;::const_iterator, Allocator&gt;&amp; m,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</A> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>regex_match(s.begin(), s.end(), m, e,
flags)</CODE>.</P><PRE>template &lt;class charT, class traits, class Allocator2&gt;
bool regex_match(const charT* str,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</A> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>regex_match(str, str +
char_traits&lt;charT&gt;::length(str), e, flags)</CODE>.</P><PRE>template &lt;class ST, class SA, class charT, class traits, class Allocator2&gt;
bool regex_match(const basic_string&lt;charT, ST, SA&gt;&amp; s,
const <A href="basic_regex.html">basic_regex</A>&lt;charT, traits, Allocator2&gt;&amp; e,
<A href="match_flag_type.html">match_flag_type</A> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>regex_match(s.begin(), s.end(), e,
flags)</CODE>.
<H3><A name="examples"></A>Examples</H3>
<P>The following <A href="../example/snippets/regex_match_example.cpp">example</A>
processes an ftp response:
<P></P>
<PRE><FONT color=#008000>#include &lt;stdlib.h&gt;
#include &lt;boost/regex.hpp&gt;
#include &lt;string&gt;
#include &lt;iostream&gt;
</FONT><B>using namespace</B> boost;
regex expression(<FONT color=#000080>"([0-9]+)(\\-| |$)(.*)"</FONT>);
<FONT color=#000080><I>// process_ftp:
// on success returns the ftp response code, and fills
// msg with the ftp response message.
</I></FONT><B>int</B> process_ftp(<B>const</B> <B>char</B>* response, std::string* msg)
{
&nbsp;&nbsp; cmatch what;
&nbsp;&nbsp; <B>if</B>(regex_match(response, what, expression))
&nbsp;&nbsp; {
<FONT color=#000080>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <I>// what[0] contains the whole string
</I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <I>// what[1] contains the response code
</I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <I>// what[2] contains the separator character
</I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <I>// what[3] contains the text message.
</I></FONT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>if</B>(msg)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; msg-&gt;assign(what[3].first, what[3].second);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>return</B> std::atoi(what[1].first);
&nbsp;&nbsp; }
<FONT color=#000080>&nbsp;&nbsp; <I>// failure did not match
</I></FONT>&nbsp;&nbsp; <B>if</B>(msg)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; msg-&gt;erase();
&nbsp;&nbsp; <B>return</B> -1;
}
<P>
<HR></PRE>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

46
doc/regex_merge.html Normal file
View File

@ -0,0 +1,46 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Algorithm regex_merge (deprecated)</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">Algorithm regex_merge (deprecated)</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<P>Algorithm regex_merge has been renamed <A href="regex_replace.html">regex_replace</A>,
existing code will continue to compile, but newcode should use <A href="regex_replace.html">
regex_replace</A> instead.</P>
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

208
doc/regex_replace.html Normal file
View File

@ -0,0 +1,208 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Algorithm regex_replace</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<LINK href="../../../boost.css" type="text/css" rel="stylesheet"></head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td vAlign="top" width="300">
<h3><A href="../../../index.htm"><IMG height="86" alt="C++ Boost" src="../../../c++boost.gif" width="277" border="0"></A></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">Algorithm regex_replace</H2>
</TD>
<td width="50">
<h3><A href="index.html"><IMG height="45" alt="Boost.Regex Index" src="uarrow.gif" width="43" border="0"></A></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<H3>Contents</H3>
<dl class="index">
<dt><A href="#synopsis">Synopsis</A> <dt><a href="#description">Description</a> <dt><A href="#examples">
Examples</A></dt></dl>
<H3><A name="synopsis"></A>Synopsis</H3>
<PRE>#include &lt;<A href="../../../boost/regex.hpp">boost/regex.hpp</A>&gt; </PRE>
<P>The algorithm regex_replace&nbsp;searches&nbsp;through&nbsp;a string finding
all the matches to the regular expression: for each match it then calls <A href="match_results.html">
match_results::format</A> to format the string and sends the result to the
output iterator. Sections of text that do not match are copied to the output
unchanged only if the <EM>flags</EM> parameter does not have the flag <A href="match_flags.html">
format_no_copy</A> set. If the flag <A href="match_flags.html">format_first_only</A>
is set then only the first occurance is replaced rather than all
occurrences.&nbsp;<PRE>template &lt;class OutputIterator, class BidirectionalIterator, class traits,
class Allocator, class charT&gt;
OutputIterator regex_replace(OutputIterator out,
BidirectionalIterator first,
BidirectionalIterator last,
const basic_regex&lt;charT, traits, Allocator&gt;&amp; e,
const basic_string&lt;charT&gt;&amp; fmt,
match_flag_type flags = match_default);
template &lt;class traits, class Allocator, class charT&gt;
basic_string&lt;charT&gt; regex_replace(const basic_string&lt;charT&gt;&amp; s,
const basic_regex&lt;charT, traits, Allocator&gt;&amp; e,
const basic_string&lt;charT&gt;&amp; fmt,
match_flag_type flags = match_default);
</PRE>
<H3><A name="description"></A>Description</H3>
<PRE>template &lt;class OutputIterator, class BidirectionalIterator, class traits,
class Allocator, class charT&gt;
OutputIterator regex_replace(OutputIterator out,
BidirectionalIterator first,
BidirectionalIterator last,
const basic_regex&lt;charT, traits, Allocator&gt;&amp; e,
const basic_string&lt;charT&gt;&amp; fmt,
match_flag_type flags = match_default);</PRE>
<B>
<P>
Effects:</B> Finds all the non-overlapping matches <I>m</I> of type <CODE>match_results&lt;BidirectionalIterator&gt;
</CODE>that occur within the sequence [first, last). If no such matches are
found and <CODE>!(flags &amp; format_no_copy)</CODE> then calls <CODE>std::copy(first,
last, out)</CODE>. Otherwise, for each match found, if <CODE>!(flags &amp;
format_no_copy)</CODE> calls <CODE>std::copy(m.prefix().first, m.prefix().last,
out)</CODE>, and then calls <CODE>m.format(out, fmt, flags)</CODE>. Finally
if <CODE>!(flags &amp; format_no_copy)</CODE> calls <CODE>std::copy(last_m.suffix().first,
last_m,suffix().last, out) </CODE>where <CODE>last_m</CODE> is a copy of the
last match found. If <CODE>flags &amp; format_first_only</CODE> is non-zero
then only the first match found is replaced.</P>
<B>
<P>
Returns:</B> <CODE>out</CODE>. </P><PRE>template &lt;class traits, class Allocator, class charT&gt;
basic_string&lt;charT&gt; regex_replace(const basic_string&lt;charT&gt;&amp; s,
const basic_regex&lt;charT, traits, Allocator&gt;&amp; e,
const basic_string&lt;charT&gt;&amp; fmt,
match_flag_type flags = match_default);</PRE>
<B>
<P>
Effects:</B> Constructs an object <CODE>basic_string&lt;charT&gt; result</CODE>,
calls <CODE>regex_replace(back_inserter(result), s.begin(), s.end(), e, fmt,
flags)</CODE>, and then returns <CODE>result</CODE>.
<H3><A name="examples"></A>Examples</H3>
<P>The following <A href="../example/snippets/regex_replace_example.cpp">example</A> takes
C/C++ source code as input, and outputs syntax highlighted HTML code.</P>
<P></P>
<PRE><FONT color=#008080>#include &lt;fstream&gt;
#include &lt;sstream&gt;
#include &lt;string&gt;
#include &lt;iterator&gt;
#include &lt;boost/regex.hpp&gt;
#include &lt;fstream&gt;
#include &lt;iostream&gt;
</FONT>
<FONT color=#000080><I>// purpose:
// takes the contents of a file and transform to
// syntax highlighted code in html format
</I></FONT>
boost::regex e1, e2;
<B>extern</B> <B>const</B> <B>char</B>* expression_text;
<B>extern</B> <B>const</B> <B>char</B>* format_string;
<B>extern</B> <B>const</B> <B>char</B>* pre_expression;
<B>extern</B> <B>const</B> <B>char</B>* pre_format;
<B>extern</B> <B>const</B> <B>char</B>* header_text;
<B>extern</B> <B>const</B> <B>char</B>* footer_text;
<B>void</B> load_file(std::string&amp; s, std::istream&amp; is)
{
s.erase();
s.reserve(is.rdbuf()-&gt;in_avail());
<B>char</B> c;
<B>while</B>(is.get(c))
{
<B>if</B>(s.capacity() == s.size())
s.reserve(s.capacity() * <FONT color=#000080>3</FONT>);
s.append(<FONT color=#000080>1</FONT>, c);
}
}
<B>int</B> main(<B>int</B> argc, <B>const</B> <B>char</B>** argv)
{
try{
e1.assign(expression_text);
e2.assign(pre_expression);
<B>for</B>(<B>int</B> i = <FONT color=#000080>1</FONT>; i &lt; argc; ++i)
{
std::cout &lt;&lt; <FONT color=#0000ff>"Processing file "</FONT> &lt;&lt; argv[i] &lt;&lt; std::endl;
std::ifstream fs(argv[i]);
std::string in;
load_file(in, fs);
std::string out_name(std::string(argv[i]) + std::string(<FONT color=#0000ff>".htm"</FONT>));
std::ofstream os(out_name.c_str());
os &lt;&lt; header_text;
<FONT color=#000080><I>// strip '&lt;' and '&gt;' first by outputting to a
</I></FONT> <FONT color=#000080><I>// temporary string stream
</I></FONT> std::ostringstream t(std::ios::out | std::ios::binary);
std::ostream_iterator&lt;<B>char</B>, <B>char</B>&gt; oi(t);
boost::regex_replace(oi, in.begin(), in.end(), e2, pre_format);
<FONT color=#000080><I>// then output to final output stream
</I></FONT> <FONT color=#000080><I>// adding syntax highlighting:
</I></FONT> std::string s(t.str());
std::ostream_iterator&lt;<B>char</B>, <B>char</B>&gt; out(os);
boost::regex_replace(out, s.begin(), s.end(), e1, format_string);
os &lt;&lt; footer_text;
}
}
<STRONG>catch</STRONG>(...)
{ <STRONG>return</STRONG> -1; }
<B>return</B> <FONT color=#000080>0</FONT>;
}
<B>extern</B> <B>const</B> <B>char</B>* pre_expression = <FONT color=#0000ff>"(&lt;)|(&gt;)|\\r"</FONT>;
<B>extern</B> <B>const</B> <B>char</B>* pre_format = <FONT color=#0000ff>"(?1&lt;)(?2&gt;)"</FONT>;
<B>const</B> <B>char</B>* expression_text = <FONT color=#000080><I>// preprocessor directives: index 1
</I></FONT> <FONT color=#0000ff>"(^[[:blank:]]*#(?:[^\\\\\\n]|\\\\[^\\n[:punct:][:word:]]*[\\n[:punct:][:word:]])*)|"
</FONT> <FONT color=#000080><I>// comment: index 2
</I></FONT> <FONT color=#0000ff>"(//[^\\n]*|/\\*.*?\\*/)|"
</FONT> <FONT color=#000080><I>// literals: index 3
</I></FONT> <FONT color=#0000ff>"\\&lt;([+-]?(?:(?:0x[[:xdigit:]]+)|(?:(?:[[:digit:]]*\\.)?[[:digit:]]+(?:[eE][+-]?[[:digit:]]+)?))u?(?:(?:int(?:8|16|32|64))|L)?)\\&gt;|"
</FONT> <FONT color=#000080><I>// string literals: index 4
</I></FONT> <FONT color=#0000ff>"('(?:[^\\\\']|\\\\.)*'|\"(?:[^\\\\\"]|\\\\.)*\")|"
</FONT> <FONT color=#000080><I>// keywords: index 5
</I></FONT> <FONT color=#0000ff>"\\&lt;(__asm|__cdecl|__declspec|__export|__far16|__fastcall|__fortran|__import"
</FONT> <FONT color=#0000ff>"|__pascal|__rtti|__stdcall|_asm|_cdecl|__except|_export|_far16|_fastcall"
</FONT> <FONT color=#0000ff>"|__finally|_fortran|_import|_pascal|_stdcall|__thread|__try|asm|auto|bool"
</FONT> <FONT color=#0000ff>"|break|case|catch|cdecl|char|class|const|const_cast|continue|default|delete"
</FONT> <FONT color=#0000ff>"|do|double|dynamic_cast|else|enum|explicit|extern|false|float|for|friend|goto"
</FONT> <FONT color=#0000ff>"|if|inline|int|long|mutable|namespace|new|operator|pascal|private|protected"
</FONT> <FONT color=#0000ff>"|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_cast"
</FONT> <FONT color=#0000ff>"|struct|switch|template|this|throw|true|try|typedef|typeid|typename|union|unsigned"
</FONT> <FONT color=#0000ff>"|using|virtual|void|volatile|wchar_t|while)\\&gt;"
</FONT> ;
<B>const</B> <B>char</B>* format_string = <FONT color=#0000ff>"(?1&lt;font color=\"#008040\"&gt;$&amp;&lt;/font&gt;)"
</FONT> <FONT color=#0000ff>"(?2&lt;I&gt;&lt;font color=\"#000080\"&gt;$&amp;&lt;/font&gt;&lt;/I&gt;)"
</FONT> <FONT color=#0000ff>"(?3&lt;font color=\"#0000A0\"&gt;$&amp;&lt;/font&gt;)"
</FONT> <FONT color=#0000ff>"(?4&lt;font color=\"#0000FF\"&gt;$&amp;&lt;/font&gt;)"
</FONT> <FONT color=#0000ff>"(?5&lt;B&gt;$&amp;&lt;/B&gt;)"</FONT>;
<B>const</B> <B>char</B>* header_text = <FONT color=#0000ff>"&lt;HTML&gt;\n&lt;HEAD&gt;\n"
</FONT> <FONT color=#0000ff>"&lt;TITLE&gt;Auto-generated html formated source&lt;/TITLE&gt;\n"
</FONT> <FONT color=#0000ff>"&lt;META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=windows-1252\"&gt;\n"
</FONT> <FONT color=#0000ff>"&lt;/HEAD&gt;\n"
</FONT> <FONT color=#0000ff>"&lt;BODY LINK=\"#0000ff\" VLINK=\"#800080\" BGCOLOR=\"#ffffff\"&gt;\n"
</FONT> <FONT color=#0000ff>"&lt;P&gt; &lt;/P&gt;\n&lt;PRE&gt;"</FONT>;
<B>const</B> <B>char</B>* footer_text = <FONT color=#0000ff>"&lt;/PRE&gt;\n&lt;/BODY&gt;\n\n"</FONT>;
<HR></PRE>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

332
doc/regex_search.html Normal file
View File

@ -0,0 +1,332 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Algorithm regex_search</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<LINK href="../../../boost.css" type="text/css" rel="stylesheet"></head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td vAlign="top" width="300">
<h3><A href="../../../index.htm"><IMG height="86" alt="C++ Boost" src="../../../c++boost.gif" width="277" border="0"></A></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">Algorithm regex_search</H2>
</TD>
<td width="50">
<h3><A href="index.html"><IMG height="45" alt="Boost.Regex Index" src="uarrow.gif" width="43" border="0"></A></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<H3>Contents</H3>
<dl class="index">
<dt><A href="#synopsis">Synopsis</A> <dt><a href="#description">Description</a> <dt><A href="#examples">
Examples</A></dt></dl>
<H3><A name="synopsis"></A>Synopsis</H3>
<PRE>#include &lt;<A href="../../boost/regex.hpp">boost/regex.hpp</A>&gt; </PRE>
<P></P>
<P>The algorithm regex_search will search a range denoted by a pair of
bidirectional-iterators for a given regular expression. The algorithm uses
various heuristics to reduce the search time by only checking for a match if a
match could conceivably start at that position. The algorithm is defined as
follows:
<PRE>template &lt;class BidirectionalIterator,
class Allocator, class charT,
class traits, class Allocator2&gt;
bool regex_search(BidirectionalIterator first, BidirectionalIterator last,
<a href=match_results.html>match_results</a>&lt;BidirectionalIterator, Allocator&gt;&amp; m,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator2&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);
template &lt;class ST, class SA,
class Allocator, class charT,
class traits, class Allocator2&gt;
bool regex_search(const basic_string&lt;charT, ST, SA&gt;&amp; s,
<a href=match_results.html>match_results</a>&lt;
typename basic_string&lt;charT, ST,SA&gt;::const_iterator,
Allocator&gt;&amp; m,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator2&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);
template&lt;class charT, class Allocator, class traits,
class Allocator2&gt;
bool regex_search(const charT* str,
<a href=match_results.html>match_results</a>&lt;const charT*, Allocator&gt;&amp; m,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator2&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);
template &lt;class BidirectionalIterator, class Allocator,
class charT, class traits&gt;
bool regex_search(BidirectionalIterator first, BidirectionalIterator last,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);
template &lt;class charT, class Allocator,
class traits&gt;
bool regex_search(const charT* str,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);
template&lt;class ST, class SA,
class Allocator, class charT,
class traits&gt;
bool regex_search(const basic_string&lt;charT, ST, SA&gt;&amp; s,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);
</PRE>
<H3><A name="description"></A>Description</H3>
<PRE>template &lt;class BidirectionalIterator, class Allocator, class charT,
class traits, class Allocator2&gt;
bool regex_search(BidirectionalIterator first, BidirectionalIterator last,
<a href=match_results.html>match_results</a>&lt;BidirectionalIterator, Allocator&gt;&amp; m,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator2&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);</PRE>
<B>
<P>
Requires:</B> Type BidirectionalIterator meets the requirements of a
Bidirectional Iterator (24.1.4).</P>
<B>
<P>
Effects: </B>Determines whether there is some sub-sequence within
[first,last) that matches the regular expression <I>e</I>, parameter <I>flags</I>
is used to control how the expression is matched against the character
sequence. Returns true if such a sequence exists, false otherwise.</P><B>
<P>
Postconditions: </B>If the function returns false, then the effect on
parameter <I>m</I> is undefined, otherwise the effects on parameter <I>m</I> are
given in the table:</P>
<DIV align="center">
<CENTER>
<TABLE id="Table2" cellSpacing="1" cellPadding="7" width="624" border="1">
<TR>
<TD vAlign="top" width="50%"><B>
<P>
Element</B></P></TD>
<TD vAlign="top" width="50%"><B>
<P>
Value</B> </P></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.size()</P>
</TD>
<TD vAlign="top" width="50%">
<P>e.mark_count()</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.empty()</P>
</TD>
<TD vAlign="top" width="50%">
<P>false</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.prefix().first</P>
</TD>
<TD vAlign="top" width="50%">
<P>first</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.prefix().last</P>
</TD>
<TD vAlign="top" width="50%">
<P>m[0].first</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.prefix().matched</P>
</TD>
<TD vAlign="top" width="50%">
<P>m.prefix().first != m.prefix().second</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.suffix().first</P>
</TD>
<TD vAlign="top" width="50%">
<P>m[0].second</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.suffix().last</P>
</TD>
<TD vAlign="top" width="50%">
<P>last</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m.suffix().matched</P>
</TD>
<TD vAlign="top" width="50%">
<P>m.suffix().first != m.suffix().second</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[0].first</P>
</TD>
<TD vAlign="top" width="50%">
<P>The start of the sequence of characters that matched the regular expression</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[0].second</P>
</TD>
<TD vAlign="top" width="50%">
<P>The end of the sequence of characters that matched the regular expression</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[0].matched</P>
</TD>
<TD vAlign="top" width="50%"><CODE>
<P>
true</CODE> if a full match was found, and <CODE>false</CODE> if it was a
partial match (found as a result of the <CODE>match_partial</CODE> flag being
set).</P></TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[n].first</P>
</TD>
<TD vAlign="top" width="50%">
<P>For all integers n &lt; m.size(), the start of the sequence that matched
sub-expression <I>n</I>. Alternatively, if sub-expression n did not participate
in the match, then <I>last</I>.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[n].second</P>
</TD>
<TD vAlign="top" width="50%">
<P>For all integers n &lt; m.size(), the end of the sequence that matched
sub-expression <I>n</I>. Alternatively, if sub-expression n did not participate
in the match, then <I>last</I>.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="50%">
<P>m[n].matched</P>
</TD>
<TD vAlign="top" width="50%">
<P>For all integers n &lt; m.size(), true if sub-expression <I>n</I> participated
in the match, false otherwise.</P>
<P></P>
</TD>
</TR>
</TD></TR></TABLE>
</CENTER>
</DIV>
<PRE>template &lt;class charT, class Allocator, class traits, class Allocator2&gt;
bool regex_search(const charT* str, <a href=match_results.html>match_results</a>&lt;const charT*, Allocator&gt;&amp; m,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator2&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>regex_search(str, str +
char_traits&lt;charT&gt;::length(str), m, e, flags)</CODE>.</P><PRE>template &lt;class ST, class SA, class Allocator, class charT,
class traits, class Allocator2&gt;
bool regex_search(const basic_string&lt;charT, ST, SA&gt;&amp; s,
<a href=match_results.html>match_results</a>&lt;typename basic_string&lt;charT, ST, SA&gt;::const_iterator, Allocator&gt;&amp; m,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator2&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>regex_search(s.begin(), s.end(), m, e,
flags)</CODE>.</P><PRE>template &lt;class iterator, class Allocator, class charT,
class traits&gt;
bool regex_search(iterator first, iterator last,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Behaves "as if" by constructing an instance of <CODE><a href="match_results.html">
match_results</a>&lt;</CODE>BidirectionalIterator<CODE>&gt; what</CODE>,
and then returning the result of <CODE>regex_search(first, last, what, e, flags)</CODE>.</P><PRE>template &lt;class charT, class Allocator, class traits&gt;
bool regex_search(const charT* str
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>regex_search(str, str +
char_traits&lt;charT&gt;::length(str), e, flags)</CODE>.</P><PRE>template &lt;class ST, class SA, class Allocator, class charT,
class traits&gt;
bool regex_search(const basic_string&lt;charT, ST, SA&gt;&amp; s,
const <a href=basic_regex.html>basic_regex</a>&lt;charT, traits, Allocator&gt;&amp; e,
<a href=match_flag_type.html>match_flag_type</a> flags = match_default);</PRE>
<B>
<P>
Effects:</B> Returns the result of <CODE>regex_search(s.begin(), s.end(), e,
flags)</CODE>.
<H3><A name="examples"></A>Examples</H3>
<P>The following <A href="../example/snippets/regex_search_example.cpp">example</A>,
takes the contents of a file in the form of a string, and searches for all the
C++ class declarations in the file. The code will work regardless of the way
that std::string is implemented, for example it could easily be modified to
work with the SGI rope class, which uses a non-contiguous storage strategy.</P>
<P></P>
<PRE><FONT color=#008000>#include &lt;string&gt;
#include &lt;map&gt;
#include &lt;boost/regex.hpp&gt;
</FONT><FONT color=#000080><I>
// purpose:
// takes the contents of a file in the form of a string
// and searches for all the C++ class definitions, storing
// their locations in a map of strings/int's
</I></FONT><B>typedef</B> std::map&lt;std::string, <B>int</B>, std::less&lt;std::string&gt; &gt; map_type;
boost::regex expression("^(template[[:space:]]*&lt;[^;:{]+&gt;[[:space:]]*)?(class|struct)[[:space:]]*(\\&lt;\\w+\\&gt;([[:blank:]]*\\([^)]*\\))?[[:space:]]*)*(\\&lt;\\w*\\&gt;)[[:space:]]*(&lt;[^;:{]+&gt;[[:space:]]*)?(\\{|:[^;\\{()]*\\{)");
<B>
void</B> IndexClasses(map_type&amp; m, <B>const</B> std::string&amp; file)
{
&nbsp;&nbsp; std::string::const_iterator start, end;
&nbsp;&nbsp; start = file.begin();
&nbsp;&nbsp; end = file.end();&nbsp;
&nbsp;&nbsp; &nbsp;&nbsp; boost::<a href=match_results.html>match_results</a>&lt;std::string::const_iterator&gt; what;
&nbsp;&nbsp; <B>unsigned</B> <B>int</B> flags = boost::match_default;
&nbsp;&nbsp; <B>while</B>(regex_search(start, end, what, expression, flags))&nbsp;
&nbsp;&nbsp; {
<FONT color=#000080>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <I>// what[0] contains the whole string
</I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <I>// what[5] contains the class name.
</I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <I>// what[6] contains the template specialisation if any.
</I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <I>// add class name and position to map:
</I></FONT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m[std::string(what[5].first, what[5].second) + std::string(what[6].first, what[6].second)] =&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; what[5].first - file.begin();&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#000080><I>// update search position:
</I></FONT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; start = what[0].second;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#000080><I>// update flags:
</I></FONT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; flags |= boost::match_prev_avail;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; flags |= boost::match_not_bob;&nbsp;
&nbsp;&nbsp; }
}
<HR></PRE>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

143
doc/regex_split.html Normal file
View File

@ -0,0 +1,143 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Algorithm regex_split (deprecated)</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">Algorithm regex_split (deprecated)</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<P>The algorithm regex_split has been deprecated in favour of the iterator <A href="regex_token_iterator.html">
regex_token_iterator</A> which has a more flexible and powerful interface,
as well as following the more usual standard library "pull" rather than "push"
semantics.</P>
<P>Code which uses regex_split will continue to compile, the following
documentation is taken from the previous boost.regex version:</P>
<H3><A name="regex_split"></A>Algorithm regex_split</H3>
<PRE>#include &lt;<A href="../../../boost/regex.hpp">boost/regex.hpp</A>&gt; </PRE>
<P>Algorithm regex_split performs a similar operation to the perl split operation,
and comes in three overloaded forms:
</P>
<PRE><B>template</B> &lt;<B>class</B> OutputIterator, <B>class</B> charT, <B>class</B> Traits1, <B>class</B> Alloc1, <B>class</B> Traits2, <B>class</B> Alloc2&gt;
std::size_t regex_split(OutputIterator out,&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::basic_string&lt;charT, Traits1, Alloc1&gt;&amp; s,&nbsp;
&nbsp;<B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; const</B> basic_regex&lt;charT, Traits2, Alloc2&gt;&amp; e,
&nbsp;<B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; unsigned</B> flags,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::size_t max_split);
<B>template</B> &lt;<B>class</B> OutputIterator, <B>class</B> charT, <B>class</B> Traits1, <B>class</B> Alloc1, <B>class</B> Traits2, <B>class</B> Alloc2&gt;
std::size_t regex_split(OutputIterator out,&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::basic_string&lt;charT, Traits1, Alloc1&gt;&amp; s,&nbsp;
&nbsp;<B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; const</B> basic_regex&lt;charT, Traits2, Alloc2&gt;&amp; e,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <B>unsigned</B> flags = match_default);
<B>template</B> &lt;<B>class</B> OutputIterator, <B>class</B> charT, <B>class</B> Traits1, <B>class</B> Alloc1&gt;
std::size_t regex_split(OutputIterator out,
std::basic_string&lt;charT, Traits1, Alloc1&gt;&amp; s);</PRE>
<P>Each version takes an output-iterator for output, and a string for input. If
the expression contains no marked sub-expressions, then the algorithm writes
one string onto the output-iterator for each section of input that does not
match the expression. If the expression does contain marked sub-expressions,
then each time a match is found, one string for each marked sub-expression will
be written to the output-iterator. No more than <I>max_split </I>strings will
be written to the output-iterator. Before returning, all the input processed
will be deleted from the string <I>s</I> (if <I>max_split </I>is not reached
then all of <I>s</I> will be deleted). Returns the number of strings written to
the output-iterator. If the parameter <I>max_split</I> is not specified then it
defaults to UINT_MAX. If no expression is specified, then it defaults to "\s+",
and splitting occurs on whitespace.
</P>
<P><A href="../example/snippets/regex_split_example_1.cpp">Example</A>: the following
function will split the input string into a series of tokens, and remove each
token from the string <I>s</I>:
</P>
<PRE><B>unsigned</B> tokenise(std::list&lt;std::string&gt;&amp; l, std::string&amp; s)
{
<B>&nbsp;&nbsp; return</B> boost::regex_split(std::back_inserter(l), s);
}</PRE>
<P><A href="../example/snippets/regex_split_example_2.cpp">Example</A>: the following
short program will extract all of the URL's from a html file, and print them
out to <I>cout</I>:
</P>
<PRE><FONT color=#008000>#include &lt;list&gt;
#include &lt;fstream&gt;
#include &lt;iostream&gt;
#include &lt;boost/regex.hpp&gt;
</FONT>
boost::regex e(<FONT color=#000080>"&lt;\\s*A\\s+[^&gt;]*href\\s*=\\s*\"([^\"]*)\""</FONT>,
boost::regbase::normal | boost::regbase::icase);
<B>void</B> load_file(std::string&amp; s, std::istream&amp; is)
{
s.erase();
<FONT color=#000080>//
// attempt to grow string buffer to match file size,
// this doesn't always work...
</FONT> s.reserve(is.rdbuf()-&amp;gtin_avail());
<B>char</B> c;
<B>while</B>(is.get(c))
{
<FONT color=#000080>// use logarithmic growth stategy, in case
// in_avail (above) returned zero:
</FONT> <B>if</B>(s.capacity() == s.size())
s.reserve(s.capacity() * 3);
s.append(1, c);
}
}
<B>int</B> main(<B>int</B> argc, <B>char</B>** argv)
{
std::string s;
std::list&lt;std::string&gt; l;
<B>for</B>(<B>int</B> i = 1; i &lt; argc; ++i)
{
std::cout &lt;&lt; <FONT color=#000080>"Findings URL's in "</FONT> &lt;&lt; argv[i] &lt;&lt; <FONT color=#000080>":"</FONT> &lt;&lt; std::endl;
s.erase();
std::ifstream is(argv[i]);
load_file(s, is);
boost::regex_split(std::back_inserter(l), s, e);
<B>while</B>(l.size())
{
s = *(l.begin());
l.pop_front();
std::cout &lt;&lt; s &lt;&lt; std::endl;
}
}
<B>return</B> 0;
}</PRE>
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

47
doc/regex_traits.html Normal file
View File

@ -0,0 +1,47 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: class regex_traits</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">class regex_traits</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<P>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>.&nbsp;</P>
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

427
doc/sub_match.html Normal file
View File

@ -0,0 +1,427 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: sub_match</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">sub_match</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<H3>Synopsis</H3>
<P>#include &lt;<A href="../../boost/regex.hpp">boost/regex.hpp</A>&gt;
</P>
<P>Regular expressions are different from many simple pattern-matching algorithms
in that as well as finding an overall match they can also produce
sub-expression matches: each sub-expression being delimited in the pattern by a
pair of parenthesis (...). There has to be some method for reporting
sub-expression matches back to the user: this is achieved this by defining a
class <I><A href="match_results.htm">match_results</A></I> that acts as an
indexed collection of sub-expression matches, each sub-expression match being
contained in an object of type <I>sub_match</I>
.
<P>Objects of type <EM>sub_match</EM> may only obtained by subscripting an object
of type <EM><A href="match_results.html">match_results</A></EM>
.
<P>When the marked sub-expression denoted by an object of type sub_match&lt;&gt;
participated in a regular expression match then member <CODE>matched</CODE> evaluates
to true, and members <CODE>first</CODE> and <CODE>second</CODE> denote the
range of characters <CODE>[first,second)</CODE> which formed that match.
Otherwise <CODE>matched</CODE> is false, and members <CODE>first</CODE> and <CODE>second</CODE>
contained undefined values.</P>
<P>If an object of type <CODE>sub_match&lt;&gt;</CODE> represents sub-expression 0
- that is to say the whole match - then member <CODE>matched</CODE> is always
true, unless a partial match was obtained as a result of the flag <CODE>match_partial</CODE>
being passed to a regular expression algorithm, in which case member <CODE>matched</CODE>
is false, and members <CODE>first</CODE> and <CODE>second</CODE> represent the
character range that formed the partial match.</P>
<PRE>
namespace boost{
template &lt;class BidirectionalIterator&gt;
class sub_match : public std::pair&lt;BidirectionalIterator, BidirectionalIterator&gt;
{
public:
typedef typename iterator_traits&lt;BidirectionalIterator&gt;::value_type value_type;
typedef typename iterator_traits&lt;BidirectionalIterator&gt;::difference_type difference_type;
typedef BidirectionalIterator iterator;
bool matched;
difference_type length()const;
operator basic_string&lt;value_type&gt;()const;
basic_string&lt;value_type&gt; str()const;
int compare(const sub_match&amp; s)const;
int compare(const basic_string&lt;value_type&gt;&amp; s)const;
int compare(const value_type* s)const;
};
template &lt;class BidirectionalIterator&gt;
bool operator == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool operator == (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool operator != (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool operator &lt; (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool operator &gt; (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool operator &gt;= (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool operator &lt;= (const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool operator == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool operator != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool operator &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool operator &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool operator &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; rhs);
template &lt;class BidirectionalIterator, class traits, class Allocator&gt;
bool operator &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const std::basic_string&lt;iterator_traits&lt;BidirectionalIterator&gt;<TYPENAME re_detail::regex_iterator_traits><RANDOMACCESSITERATOR>::value_type, traits, Allocator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator == (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator != (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &lt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &gt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &gt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &lt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs);
template &lt;class BidirectionalIterator&gt;
bool operator != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs);
template &lt;class BidirectionalIterator&gt;
bool operator == (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator != (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &lt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &gt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &gt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &lt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs);
template &lt;class BidirectionalIterator&gt;
bool operator &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs);
template &lt;class charT, class traits, class BidirectionalIterator&gt;
basic_ostream&lt;charT, traits&gt;&amp;
operator &lt;&lt; (basic_ostream&lt;charT, traits&gt;&amp; os,
const sub_match&lt;BidirectionalIterator&gt;&amp; m);
} // namespace boost</PRE>
<H3>Description</H3>
<H4>
sub_match members</H4>
<PRE>typedef typename std::iterator_traits&lt;iterator&gt;::value_type value_type;</PRE>
<P>The type pointed to by the iterators.</P>
<PRE>typedef typename std::iterator_traits&lt;iterator&gt;::difference_type difference_type;</PRE>
<P>A type that represents the difference between two iterators.</P>
<PRE>typedef iterator iterator_type;</PRE>
<P>The iterator type.</P>
<PRE>iterator first</PRE>
<P>An iterator denoting the position of the start of the match.</P>
<PRE>iterator second</PRE>
<P>An iterator denoting the position of the end of the match.</P>
<PRE>bool matched</PRE>
<P>A Boolean value denoting whether this sub-expression participated in the match.</P>
<PRE>static difference_type length();</PRE>
<B>
<P>
Effects: </B>returns <CODE>(matched ? 0 : distance(first, second))</CODE>.</P><PRE>operator basic_string&lt;value_type&gt;()const;</PRE>
<B>
<P>
Effects: </B>returns <CODE>(matched ? basic_string&lt;value_type&gt;(first,
second) : basic_string&lt;value_type&gt;()).</P></CODE><PRE>basic_string&lt;value_type&gt; str()const;</PRE>
<B>
<P>
Effects: </B>returns <CODE>(matched ? basic_string&lt;value_type&gt;(first,
second) : basic_string&lt;value_type&gt;())</CODE>.</P><PRE>int compare(const sub_match&amp; s)const;</PRE>
<B>
<P>
Effects: </B>returns <CODE>str().compare(s.str())</CODE>.</P><PRE>int compare(const basic_string&lt;value_type&gt;&amp; s)const;</PRE>
<B>
<P>
Effects: </B>returns <CODE>str().compare(s)</CODE>.</P><PRE>int compare(const value_type* s)const;</PRE>
<B>
<P>
Effects: </B>returns <CODE>str().compare(s)</CODE>.</P>
<H4>
sub_match non-member operators</H4>
<PRE>template &lt;class BidirectionalIterator&gt;
bool operator == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);</PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs.compare(rhs) == 0</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);</PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs.compare(rhs) != 0</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);</PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs.compare(rhs) &lt; 0</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);</PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs.compare(rhs) &lt;= 0</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);</PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs.compare(rhs) &gt;= 0</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs);</PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs.compare(rhs) &gt; 0</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator == (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs == rhs.str()</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator != (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs != rhs.str()</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &lt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs &lt; rhs.str()</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &gt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs &gt; rhs.str()</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &gt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs &gt;= rhs.str()</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &lt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs &lt;= rhs.str()</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs.str() == rhs</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs.str() != rhs</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs.str() &lt; rhs</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs.str() &gt; rhs</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs.str() &gt;= rhs</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const* rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs.str() &lt;= rhs</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator == (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs == rhs.str()</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator != (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs != rhs.str()</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &lt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs &lt; rhs.str()</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &gt; (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs &gt; rhs.str()</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &gt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs &gt;= rhs.str()</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &lt;= (typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; lhs,
const sub_match&lt;BidirectionalIterator&gt;&amp; rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs &lt;= rhs.str()</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator == (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs.str() == rhs</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator != (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs.str() != rhs</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &lt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs.str() &lt; rhs</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &gt; (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs.str() &gt; rhs</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &gt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs.str() &gt;= rhs</CODE>.</P><PRE>template &lt;class BidirectionalIterator&gt;
bool operator &lt;= (const sub_match&lt;BidirectionalIterator&gt;&amp; lhs,
typename iterator_traits&lt;BidirectionalIterator&gt;::value_type const&amp; rhs); </PRE>
<B>
<P>
Effects: </B>returns <CODE>lhs.str() &lt;= rhs</CODE>.</P><PRE>template &lt;class charT, class traits, class BidirectionalIterator&gt;
basic_ostream&lt;charT, traits&gt;&amp;
operator &lt;&lt; (basic_ostream&lt;charT, traits&gt;&amp; os
const sub_match&lt;BidirectionalIterator&gt;&amp; m);</PRE>
<B>
<P>
Effects: </B>returns <CODE>(os &lt;&lt; m.str())</CODE>.
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

783
doc/syntax.html Normal file
View File

@ -0,0 +1,783 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Regular Expression Syntax</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">Regular Expression Syntax</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<P>This section covers the regular expression syntax used by this library, this is
a programmers guide, the actual syntax presented to your program's users will
depend upon the flags used during expression compilation.
</P>
<H3>Literals
</H3>
<P>All characters are literals except: ".", "|", "*", "?", "+", "(", ")", "{",
"}", "[", "]", "^", "$" and "\". These characters are literals when preceded by
a "\". A literal is a character that matches itself, or matches the result of
traits_type::translate(), where traits_type is the traits template parameter to
class reg_expression.</P>
<H3>Wildcard
</H3>
<P>The dot character "." matches any single character except : when <I>match_not_dot_null</I>
is passed to the matching algorithms, the dot does not match a null character;
when <I>match_not_dot_newline</I> is passed to the matching algorithms, then
the dot does not match a newline character.
</P>
<H3>Repeats
</H3>
<P>A repeat is an expression that is repeated an arbitrary number of times. An
expression followed by "*" can be repeated any number of times including zero.
An expression followed by "+" can be repeated any number of times, but at least
once, if the expression is compiled with the flag regex_constants::bk_plus_qm
then "+" is an ordinary character and "\+" represents a repeat of once or more.
An expression followed by "?" may be repeated zero or one times only, if the
expression is compiled with the flag regex_constants::bk_plus_qm then "?" is an
ordinary character and "\?" represents the repeat zero or once operator. When
it is necessary to specify the minimum and maximum number of repeats
explicitly, the bounds operator "{}" may be used, thus "a{2}" is the letter "a"
repeated exactly twice, "a{2,4}" represents the letter "a" repeated between 2
and 4 times, and "a{2,}" represents the letter "a" repeated at least twice with
no upper limit. Note that there must be no white-space inside the {}, and there
is no upper limit on the values of the lower and upper bounds. When the
expression is compiled with the flag regex_constants::bk_braces then "{" and
"}" are ordinary characters and "\{" and "\}" are used to delimit bounds
instead. All repeat expressions refer to the shortest possible previous
sub-expression: a single character; a character set, or a sub-expression
grouped with "()" for example.
</P>
<P>Examples:
</P>
<P>"ba*" will match all of "b", "ba", "baaa" etc.
</P>
<P>"ba+" will match "ba" or "baaaa" for example but not "b".
</P>
<P>"ba?" will match "b" or "ba".
</P>
<P>"ba{2,4}" will match "baa", "baaa" and "baaaa".
</P>
<H3>Non-greedy repeats
</H3>
<P>Whenever the "extended" regular expression syntax is in use (the default) then
non-greedy repeats are possible by appending a '?' after the repeat; a
non-greedy repeat is one which will match the <I>shortest</I> possible string.
</P>
<P>For example to match html tag pairs one could use something like:
</P>
<P>"&lt;\s*tagname[^&gt;]*&gt;(.*?)&lt;\s*/tagname\s*&gt;"
</P>
<P>In this case $1 will contain the text between the tag pairs, and will be the
shortest possible matching string.&nbsp;
</P>
<H3>Parenthesis
</H3>
<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="template_class_ref.htm#query_match">
regex_match</A> and <A href="template_class_ref.htm#reg_search">regex_search</A>
each take an instance of <A href="template_class_ref.htm#reg_match">match_results</A>
that reports what caused the match, on exit from these functions the <A href="template_class_ref.htm#reg_match">
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>
<P>Sometimes you need to group sub-expressions with parenthesis, but don't want
the parenthesis to spit out another marked sub-expression, in this case a
non-marking parenthesis (?:expression) can be used. For example the following
expression creates no sub-expressions:
</P>
<P>"(?:abc)*"</P>
<H3>Forward Lookahead Asserts&nbsp;
</H3>
<P>There are two forms of these; one for positive forward lookahead asserts, and
one for negative lookahead asserts:</P>
<P>"(?=abc)" matches zero characters only if they are followed by the expression
"abc".</P>
<P>"(?!abc)" matches zero characters only if they are not followed by the
expression "abc".</P>
<H3>Independent sub-expressions</H3>
<P>"(?&gt;expression)" matches "expression" as an independent atom (the algorithm
will not backtrack into it if a failure occures later in the expression).</P>
<H3>Alternatives
</H3>
<P>Alternatives occur when the expression can match either one sub-expression or
another, each alternative is separated by a "|", or a "\|" if the flag
regex_constants::bk_vbar is set, or by a newline character if the flag
regex_constants::newline_alt is set. Each alternative is the largest possible
previous sub-expression; this is the opposite behaviour from repetition
operators.
</P>
<P>Examples:
</P>
<P>"a(b|c)" could match "ab" or "ac".
</P>
<P>"abc|def" could match "abc" or "def".
</P>
<H3>Sets
</H3>
<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
elements that follow.
</P>
<P>Examples:
</P>
<P>Character literals:
</P>
<P>"[abc]" will match either of "a", "b", or "c".
</P>
<P>"[^abc] will match any character other than "a", "b", or "c".
</P>
<P>Character ranges:
</P>
<P>"[a-z]" will match any character in the range "a" to "z".
</P>
<P>"[^A-Z]" will match any character other than those in the range "A" to "Z".
</P>
<P>Note that character ranges are highly locale dependent if the flag
regex_constants::collate is set: they match any character that collates between
the endpoints of the range, ranges will only behave according to ASCII rules
when the default "C" locale is in effect. For example if the library is
compiled with the Win32 localization model, then [a-z] will match the ASCII
characters a-z, and also 'A', 'B' etc, but not 'Z' which collates just after
'z'. This locale specific behaviour is disabled by default (in perl mode), and
forces ranges to collate according to ASCII character code.
</P>
<P>Character classes are denoted using the syntax "[:classname:]" within a set
declaration, for example "[[:space:]]" is the set of all whitespace characters.
Character classes are only available if the flag regex_constants::char_classes
is set. The available character classes are:
<BR>
&nbsp;
</P>
<P>
<TABLE id="Table2" cellSpacing="0" cellPadding="7" width="100%" border="0">
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="50%">alnum</TD>
<TD vAlign="top" width="50%">Any alpha numeric character.</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">alpha</TD>
<TD vAlign="top" width="50%">Any alphabetical character a-z and A-Z. Other
characters may also be included depending upon the locale.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">blank</TD>
<TD vAlign="top" width="50%">Any blank character, either a space or a tab.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">cntrl</TD>
<TD vAlign="top" width="50%">Any control character.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">digit</TD>
<TD vAlign="top" width="50%">Any digit 0-9.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">graph</TD>
<TD vAlign="top" width="50%">Any graphical character.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">lower</TD>
<TD vAlign="top" width="50%">Any lower case character a-z. Other characters may
also be included depending upon the locale.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">print</TD>
<TD vAlign="top" width="50%">Any printable character.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">punct</TD>
<TD vAlign="top" width="50%">Any punctuation character.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">space</TD>
<TD vAlign="top" width="50%">Any whitespace character.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">upper</TD>
<TD vAlign="top" width="50%">Any upper case character A-Z. Other characters may
also be included depending upon the locale.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">xdigit</TD>
<TD vAlign="top" width="50%">Any hexadecimal digit character, 0-9, a-f and A-F.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">word</TD>
<TD vAlign="top" width="50%">Any word character - all alphanumeric characters plus
the underscore.</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="50%">unicode</TD>
<TD vAlign="top" width="50%">Any character whose code is greater than 255, this
applies to the wide character traits classes only.</TD>
<TD>&nbsp;</TD>
</TR>
</TABLE>
</P>
<P>There are some shortcuts that can be used in place of the character classes,
provided the flag regex_constants::escape_in_lists is set then you can use:
</P>
<P>\w in place of [:word:]
</P>
<P>\s in place of [:space:]
</P>
<P>\d in place of [:digit:]
</P>
<P>\l in place of [:lower:]
</P>
<P>\u in place of [:upper:]&nbsp;
</P>
<P>Collating elements take the general form [.tagname.] inside a set declaration,
where <I>tagname</I> is either a single character, or a name of a collating
element, for example [[.a.]] is equivalent to [a], and [[.comma.]] is
equivalent to [,]. The library supports all the standard POSIX collating
element names, and in addition the following digraphs: "ae", "ch", "ll", "ss",
"nj", "dz", "lj", each in lower, upper and title case variations.
Multi-character collating elements can result in the set matching more than one
character, for example [[.ae.]] would match two characters, but note that
[^[.ae.]] would only match one character.&nbsp;
</P>
<P>
Equivalence classes take the general form[=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
a set of characters that collate the same, a primary equivalence class is a set
of characters whose primary sort key are all the same (for example strings are
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
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
equivalence classes are probably best considered broken under any operating
system other than Win32.&nbsp;
</P>
<P>To include a literal "-" in a set declaration then: make it the first character
after the opening "[" or "[^", the endpoint of a range, a collating element, or
if the flag regex_constants::escape_in_lists is set then precede with an escape
character as in "[\-]". To include a literal "[" or "]" or "^" in a set then
make them the endpoint of a range, a collating element, or precede with an
escape character if the flag regex_constants::escape_in_lists is set.
</P>
<H3>Line anchors
</H3>
<P>An anchor is something that matches the null string at the start or end of a
line: "^" matches the null string at the start of a line, "$" matches the null
string at the end of a line.
</P>
<H3>Back references
</H3>
<P>A back reference is a reference to a previous sub-expression that has already
been matched, the reference is to what the sub-expression matched, not to the
expression itself. A back reference consists of the escape character "\"
followed by a digit "1" to "9", "\1" refers to the first sub-expression, "\2"
to the second etc. For example the expression "(.*)\1" matches any string that
is repeated about its mid-point for example "abcabc" or "xyzxyz". A back
reference to a sub-expression that did not participate in any match, matches
the null string: NB this is different to some other regular expression
matchers. Back references are only available if the expression is compiled with
the flag regex_constants::bk_refs set.
</P>
<H3>Characters by code
</H3>
<P>This is an extension to the algorithm that is not available in other libraries,
it consists of the escape character followed by the digit "0" followed by the
octal character code. For example "\023" represents the character whose octal
code is 23. Where ambiguity could occur use parentheses to break the expression
up: "\0103" represents the character whose code is 103, "(\010)3 represents the
character 10 followed by "3". To match characters by their hexadecimal code,
use \x followed by a string of hexadecimal digits, optionally enclosed inside
{}, for example \xf0 or \x{aff}, notice the latter example is a Unicode
character.</P>
<H3>Word operators
</H3>
<P>The following operators are provided for compatibility with the GNU regular
expression library.
</P>
<P>"\w" matches any single character that is a member of the "word" character
class, this is identical to the expression "[[:word:]]".
</P>
<P>"\W" matches any single character that is not a member of the "word" character
class, this is identical to the expression "[^[:word:]]".
</P>
<P>"\&lt;" matches the null string at the start of a word.
</P>
<P>"\&gt;" matches the null string at the end of the word.
</P>
<P>"\b" matches the null string at either the start or the end of a word.
</P>
<P>"\B" matches a null string within a word.
</P>
<P>The start of the sequence passed to the matching algorithms is considered to be
a potential start of a word unless the flag match_not_bow is set. The end of
the sequence passed to the matching algorithms is considered to be a potential
end of a word unless the flag match_not_eow is set.
</P>
<H3>Buffer operators
</H3>
<P>The following operators are provide for compatibility with the GNU regular
expression library, and Perl regular expressions:
</P>
<P>"\`" matches the start of a buffer.
</P>
<P>"\A" matches the start of the buffer.
</P>
<P>"\'" matches the end of a buffer.
</P>
<P>"\z" matches the end of a buffer.
</P>
<P>"\Z" matches the end of a buffer, or possibly one or more new line characters
followed by the end of the buffer.
</P>
<P>A buffer is considered to consist of the whole sequence passed to the matching
algorithms, unless the flags match_not_bob or match_not_eob are set.
</P>
<H3>Escape operator
</H3>
<P>The escape character "\" has several meanings.
</P>
<P>Inside a set declaration the escape character is a normal character unless the
flag regex_constants::escape_in_lists is set in which case whatever follows the
escape is a literal character regardless of its normal meaning.
</P>
<P>The escape operator may introduce an operator for example: back references, or
a word operator.
</P>
<P>The escape operator may make the following character normal, for example "\*"
represents a literal "*" rather than the repeat operator.
</P>
<H4>Single character escape sequences
</H4>
<P>The following escape sequences are aliases for single characters:
<BR>
&nbsp;
</P>
<P>
<TABLE id="Table3" cellSpacing="0" cellPadding="7" width="100%" border="0">
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="33%">Escape sequence
</TD>
<TD vAlign="top" width="33%">Character code
</TD>
<TD vAlign="top" width="33%">Meaning
</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="33%">\a
</TD>
<TD vAlign="top" width="33%">0x07
</TD>
<TD vAlign="top" width="33%">Bell character.
</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="33%">\f
</TD>
<TD vAlign="top" width="33%">0x0C
</TD>
<TD vAlign="top" width="33%">Form feed.
</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="33%">\n
</TD>
<TD vAlign="top" width="33%">0x0A
</TD>
<TD vAlign="top" width="33%">Newline character.
</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="33%">\r
</TD>
<TD vAlign="top" width="33%">0x0D
</TD>
<TD vAlign="top" width="33%">Carriage return.
</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="33%">\t
</TD>
<TD vAlign="top" width="33%">0x09
</TD>
<TD vAlign="top" width="33%">Tab character.
</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="33%">\v
</TD>
<TD vAlign="top" width="33%">0x0B
</TD>
<TD vAlign="top" width="33%">Vertical tab.
</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="33%">\e
</TD>
<TD vAlign="top" width="33%">0x1B
</TD>
<TD vAlign="top" width="33%">ASCII Escape character.
</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="33%">\0dd
</TD>
<TD vAlign="top" width="33%">0dd
</TD>
<TD vAlign="top" width="33%">An octal character code, where <I>dd</I> is one or
more octal digits.
</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="33%">\xXX
</TD>
<TD vAlign="top" width="33%">0xXX
</TD>
<TD vAlign="top" width="33%">A hexadecimal character code, where XX is one or more
hexadecimal digits.
</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="33%">\x{XX}
</TD>
<TD vAlign="top" width="33%">0xXX
</TD>
<TD vAlign="top" width="33%">A hexadecimal character code, where XX is one or more
hexadecimal digits, optionally a unicode character.
</TD>
<TD>&nbsp;</TD>
</TR>
<TR>
<TD>&nbsp;</TD>
<TD vAlign="top" width="33%">\cZ
</TD>
<TD vAlign="top" width="33%">z-@
</TD>
<TD vAlign="top" width="33%">An ASCII escape sequence control-Z, where Z is any
ASCII character greater than or equal to the character code for '@'.
</TD>
<TD>&nbsp;</TD>
</TR>
</TABLE>
</P>
<H4>Miscellaneous escape sequences:
</H4>
<P>The following are provided mostly for perl compatibility, but note that there
are some differences in the meanings of \l \L \u and \U:
<BR>
&nbsp;
</P>
<P>
<TABLE id="Table4" cellSpacing="0" cellPadding="6" width="100%" border="0">
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">\w
</TD>
<TD vAlign="top" width="45%">Equivalent to [[:word:]].
</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">\W
</TD>
<TD vAlign="top" width="45%">Equivalent to [^[:word:]].
</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">\s
</TD>
<TD vAlign="top" width="45%">Equivalent to [[:space:]].
</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">\S
</TD>
<TD vAlign="top" width="45%">Equivalent to [^[:space:]].
</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">\d
</TD>
<TD vAlign="top" width="45%">Equivalent to [[:digit:]].
</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">\D
</TD>
<TD vAlign="top" width="45%">Equivalent to [^[:digit:]].
</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">\l
</TD>
<TD vAlign="top" width="45%">Equivalent to [[:lower:]].
</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">\L
</TD>
<TD vAlign="top" width="45%">Equivalent to [^[:lower:]].
</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">\u
</TD>
<TD vAlign="top" width="45%">Equivalent to [[:upper:]].
</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">\U
</TD>
<TD vAlign="top" width="45%">Equivalent to [^[:upper:]].
</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">\C
</TD>
<TD vAlign="top" width="45%">Any single character, equivalent to '.'.
</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">\X
</TD>
<TD vAlign="top" width="45%">Match any Unicode combining character sequence, for
example "a\x 0301" (a letter a with an acute).
</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">\Q
</TD>
<TD vAlign="top" width="45%">The begin quote operator, everything that follows is
treated as a literal character until a \E end quote operator is found.
</TD>
<TD width="5%">&nbsp;</TD>
</TR>
<TR>
<TD width="5%">&nbsp;</TD>
<TD vAlign="top" width="45%">\E
</TD>
<TD vAlign="top" width="45%">The end quote operator, terminates a sequence begun
with \Q.
</TD>
<TD width="5%">&nbsp;</TD>
</TR>
</TABLE>
</P>
<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 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:
<P></P>
<P>
<DIV align="center">
<P></P>
<P align="center">
<CENTER>
<TABLE id="Table5" cellSpacing="1" cellPadding="7" width="624" border="1">
<TBODY>
<TR>
<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%"><CODE>
<P>
a|ab</CODE>
</P>
</TD>
<TD vAlign="top" width="25%"><CODE>
<P>
xaby</CODE>
</P>
</TD>
<TD vAlign="top" width="25%"><CODE>
<P>
"ab"</CODE></P></TD>
<TD vAlign="top" width="25%"><CODE>
<P>
"a"</CODE></P></TD>
</TR>
<TR>
<TD vAlign="top" width="25%"><CODE>
<P>
.*([[:alnum:]]+).*</CODE></P></TD>
<TD vAlign="top" width="25%"><CODE>
<P>
" 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%"><CODE>
<P>
.*(a|xayy)</CODE></P></TD>
<TD vAlign="top" width="25%"><CODE>
<P>
zzxayyzz</CODE></P></TD>
<TD vAlign="top" width="25%"><CODE>
<P>
"zzxayy"</CODE></P></TD>
<TD vAlign="top" width="25%"><CODE>
<P>"zzxa"</P>
<P></P>
</CODE>
</TD>
</TR>
</TBODY></CODE></TD></TR></TABLE></CENTER>
<P></P>
</DIV>
<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.
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

334
doc/syntax_option_type.html Normal file
View File

@ -0,0 +1,334 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: syntax_option_type</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">syntax_option_type</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<H3>Synopsis</H3>
<P>Type syntax_option type is an implementation defined bitmask type that controls
how a regular expression string is to be interpreted.&nbsp; 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;
// these flags are standardized:
static const syntax_option_type normal;
static const syntax_option_type icase;
static const syntax_option_type nosubs;
static const syntax_option_type optimize;
static const syntax_option_type collate;
static const syntax_option_type ECMAScript = normal;
static const syntax_option_type JavaScript = normal;
static const syntax_option_type JScript = normal;
static const syntax_option_type basic;
static const syntax_option_type extended;
static const syntax_option_type awk;
static const syntax_option_type grep;
static const syntax_option_type egrep;
static const syntax_option_type sed = basic;
static const syntax_option_type perl;<BR>// these are boost.regex specific:<BR>static const syntax_option_type escape_in_lists;<BR>static const syntax_option_type char_classes;<BR>static const syntax_option_type intervals;<BR>static const syntax_option_type limited_ops;<BR>static const syntax_option_type newline_alt;<BR>static const syntax_option_type bk_plus_qm;<BR>static const syntax_option_type bk_braces;<BR>static const syntax_option_type bk_parens;<BR>static const syntax_option_type bk_refs;<BR>static const syntax_option_type bk_vbar;<BR>static const syntax_option_type use_except;<BR>static const syntax_option_type failbit;<BR>static const syntax_option_type literal;<BR>static const syntax_option_type nocollate;<BR>static const syntax_option_type perlex;<BR>static const syntax_option_type emacs;<BR>
} // namespace regex_constants
} // namespace std</PRE>
<H3>Description</H3>
<P>The type <CODE>syntax_option_type</CODE> is an implementation defined 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
or perl</CODE> set.</P>
<P>Note that for convenience all the constants listed here are duplicated within
the scope of class template basic_regex, so you can use any of:</P>
<PRE>boost::regex_constants::constant_name</PRE>
<P>or</P>
<PRE>boost::regex::constant_name</PRE>
<P>or</P>
<PRE>boost::wregex::constant_name</PRE>
<P>in an interchangeable manner.</P>
<P>
<TABLE id="Table2" height="1274" cellSpacing="1" cellPadding="7" width="100%" border="0">
<TR>
<TD vAlign="top" width="316">
<P>Element</P>
</TD>
<TD vAlign="top" width="50%">
<P>Effect if set</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="316">
<P>normal</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that the grammar recognized by the regular expression engine uses its
normal semantics: that is the same as that given in the ECMA-262, ECMAScript
Language Specification, Chapter 15 part 10, RegExp (Regular Expression) Objects
(FWD.1).</P>
<P>boost.regex also recognises most perl-compatible extensions in this mode.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="316">
<P>icase</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that matching of regular expressions against a character container
sequence shall be performed without regard to case.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="316">
<P>nosubs</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that when a regular expression is matched against a character
container sequence, then no sub-expression matches are to be stored in the
supplied match_results structure.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="316">
<P>optimize</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that the regular expression engine should pay more attention to the
speed with which regular expressions are matched, and less to the speed with
which regular expression objects are constructed. Otherwise it has no
detectable effect on the program output.&nbsp; This currently has no effect for
boost.regex.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="316">
<P>collate</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that character ranges of the form "[a-b]" should be locale sensitive.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="316">
<P>ECMAScript</P>
</TD>
<TD vAlign="top" width="50%">
<P>The same as normal.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="316">
<P>JavaScript</P>
</TD>
<TD vAlign="top" width="50%">
<P>The same as normal.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="316">
<P>JScript</P>
</TD>
<TD vAlign="top" width="50%">
<P>The same as normal.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="316">
<P>basic</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that the grammar recognized by the regular expression engine is the
same as that used by POSIX basic regular expressions in IEEE Std 1003.1-2001,
Portable Operating System Interface (POSIX ), Base Definitions and Headers,
Section 9, Regular Expressions (FWD.1).
</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="316">
<P>extended</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that the grammar recognized by the regular expression engine is the
same as that used by POSIX extended regular expressions in IEEE Std
1003.1-2001, Portable Operating System Interface (POSIX ), Base Definitions and
Headers, Section 9, Regular Expressions (FWD.1).</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="316">
<P>awk</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that the grammar recognized by the regular expression engine is the
same as that used by POSIX utility awk in IEEE Std 1003.1-2001, Portable
Operating System Interface (POSIX ), Shells and Utilities, Section 4, awk
(FWD.1).</P>
<P>That is to say: the same as POSIX extended syntax, but with escape sequences in
character classes permitted.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="316">
<P>grep</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that the grammar recognized by the regular expression engine is the
same as that used by POSIX utility grep in IEEE Std 1003.1-2001, Portable
Operating System Interface (POSIX ), Shells and Utilities, Section 4,
Utilities, grep (FWD.1).</P>
<P>That is to say, the same as POSIX basic syntax, but with the newline character
acting as an alternation character in addition to "|".</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="316">
<P>egrep</P>
</TD>
<TD vAlign="top" width="50%">
<P>Specifies that the grammar recognized by the regular expression engine is the
same as that used by POSIX utility grep when given the -E option in IEEE Std
1003.1-2001, Portable Operating System Interface (POSIX ), Shells and
Utilities, Section 4, Utilities, grep (FWD.1).</P>
<P>That is to say, the same as POSIX extended syntax, but with the newline
character acting as an alternation character in addition to "|".</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="316">
<P>sed</P>
</TD>
<TD vAlign="top" width="50%">
<P>The same as basic.</P>
</TD>
</TR>
<TR>
<TD vAlign="top" width="316">
<P>perl</P>
</TD>
<TD vAlign="top" width="50%">
<P>The same as normal.</P>
</TD>
</TR>
</TABLE>
</P>
<P>
<P>The following constants are specific to this particular regular expression
implementation and do not appear in the <A href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1429.htm">
regular expression standardization proposal</A>:</P>
<P>
<TABLE id="Table3" cellSpacing="0" cellPadding="7" width="100%" border="0">
<TR>
<TD vAlign="top" width="45%">regbase::escape_in_lists</TD>
<TD vAlign="top" width="45%">Allows the use of the escape "\" character in sets of
characters, for example [\]] represents the set of characters containing only
"]". If this flag is not set then "\" is an ordinary character inside sets.</TD>
</TR>
<TR>
<TD vAlign="top" width="45%">regbase::char_classes</TD>
<TD vAlign="top" width="45%">When this bit is set, character classes [:classname:]
are allowed inside character set declarations, for example "[[:word:]]"
represents the set of all characters that belong to the character class "word".</TD>
</TR>
<TR>
<TD vAlign="top" width="45%">regbase:: intervals</TD>
<TD vAlign="top" width="45%">When this bit is set, repetition intervals are
allowed, for example "a{2,4}" represents a repeat of between 2 and 4 letter
a's.</TD>
</TR>
<TR>
<TD vAlign="top" width="45%">regbase:: limited_ops</TD>
<TD vAlign="top" width="45%">When this bit is set all of "+", "?" and "|" are
ordinary characters in all situations.</TD>
</TR>
<TR>
<TD vAlign="top" width="45%">regbase:: newline_alt</TD>
<TD vAlign="top" width="45%">When this bit is set, then the newline character "\n"
has the same effect as the alternation operator "|".</TD>
</TR>
<TR>
<TD vAlign="top" width="45%">regbase:: bk_plus_qm</TD>
<TD vAlign="top" width="45%">When this bit is set then "\+" represents the one or
more repetition operator and "\?" represents the zero or one repetition
operator. When this bit is not set then "+" and "?" are used instead.</TD>
</TR>
<TR>
<TD vAlign="top" width="45%">regbase:: bk_braces</TD>
<TD vAlign="top" width="45%">When this bit is set then "\{" and "\}" are used for
bounded repetitions and "{" and "}" are normal characters. This is the opposite
of default behavior.</TD>
</TR>
<TR>
<TD vAlign="top" width="45%">regbase:: bk_parens</TD>
<TD vAlign="top" width="45%">When this bit is set then "\(" and "\)" are used to
group sub-expressions and "(" and ")" are ordinary characters, this is the
opposite of default behaviour.</TD>
</TR>
<TR>
<TD vAlign="top" width="45%">regbase:: bk_refs</TD>
<TD vAlign="top" width="45%">When this bit is set then back references are
allowed.</TD>
</TR>
<TR>
<TD vAlign="top" width="45%">regbase:: bk_vbar</TD>
<TD vAlign="top" width="45%">When this bit is set then "\|" represents the
alternation operator and "|" is an ordinary character. This is the opposite of
default behaviour.</TD>
</TR>
<TR>
<TD vAlign="top" width="45%">regbase:: use_except</TD>
<TD vAlign="top" width="45%">When this bit is set then a <A href="#bad_expression">bad_expression</A>
exception will be thrown on error.&nbsp; Use of this flag is deprecated -
reg_expression will always throw on error.</TD>
</TR>
<TR>
<TD vAlign="top" width="45%">regbase:: failbit</TD>
<TD vAlign="top" width="45%">This bit is set on error, if regbase::use_except is
not set, then this bit should be checked to see if a regular expression is
valid before usage.</TD>
</TR>
<TR>
<TD vAlign="top" width="45%">regbase::literal</TD>
<TD vAlign="top" width="45%">All characters in the string are treated as literals,
there are no special characters or escape sequences.</TD>
</TR>
<TR>
<TD vAlign="top" width="45%" height="24">regbase::emacs</TD>
<TD vAlign="top" width="45%" height="24">Provides compatability with the emacs
editor, eqivalent to: bk_braces | bk_parens | bk_refs | bk_vbar.</TD>
</TR>
</TABLE>
</P>
<P>
<HR>
</P>
<P>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></P>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

66
doc/thread_safety.html Normal file
View File

@ -0,0 +1,66 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Boost.Regex: Thread Safety</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../../boost.css">
</head>
<body>
<P>
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
<TR>
<td valign="top" width="300">
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
</td>
<TD width="353">
<H1 align="center">Boost.Regex</H1>
<H2 align="center">Thread Safety</H2>
</TD>
<td width="50">
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
</td>
</TR>
</TABLE>
</P>
<HR>
<p></p>
<P>Class basic_regex&lt;&gt; and its typedefs regex and wregex are thread safe, in
that compiled regular expressions can safely be shared between threads. The
matching algorithms regex_match, regex_search, regex_grep, regex_format and
regex_merge are all re-entrant and thread safe. Class match_results is now
thread safe, in that the results of a match can be safely copied from one
thread to another (for example one thread may find matches and push
match_results instances onto a queue, while another thread pops them off the
other end), otherwise use a separate instance of match_results per thread.
</P>
<P>The POSIX API functions are all re-entrant and thread safe, regular expressions
compiled with <I>regcomp</I> can also be shared between threads.
</P>
<P>The class RegEx is only thread safe if each thread gets its own RegEx instance
(apartment threading) - this is a consequence of RegEx handling both compiling
and matching regular expressions.
</P>
<P>Finally note that changing the global locale invalidates all compiled regular
expressions, therefore calling <I>set_locale</I> from one thread while another
uses regular expressions <I>will</I> produce unpredictable results.
</P>
<P>
There is also a requirement that there is only one thread executing prior to
the start of main().
<P>
<HR>
<P></P>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
11 April 2003
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<P><I><EFBFBD> Copyright <a href="mailto:jm@regex.fsnet.co.uk">John Maddock</a>&nbsp;1998-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></I></P>
<P align="left"><I>Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting documentation.
Dr John Maddock makes no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.</I></P>
</body>
</html>

BIN
doc/uarrow.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -38,6 +38,7 @@ test-suite regex-examples :
[ regex-test-run snippets/regex_grep_example_4.cpp : $(BOOST_ROOT)/boost/rational.hpp ]
[ regex-test-run snippets/regex_match_example.cpp : -auto ]
[ regex-test-run snippets/regex_merge_example.cpp : $(BOOST_ROOT)/boost/rational.hpp ]
[ regex-test-run snippets/regex_replace_example.cpp : $(BOOST_ROOT)/boost/rational.hpp ]
[ regex-test-run snippets/regex_search_example.cpp : $(BOOST_ROOT)/boost/rational.hpp ]
[ regex-test-run snippets/regex_split_example_1.cpp : -auto ]
[ regex-test-run snippets/regex_split_example_2.cpp : $(BOOST_ROOT)/libs/regex/index.htm ]

View File

@ -232,14 +232,14 @@ void HandleArg(const char* arg)
{
if(words_only == 0)
{
e.set_expression(arg, use_case ? regbase::normal : regbase::normal | regbase::icase);
e.set_expression(arg, use_case ? regex::normal : regbase::normal | regbase::icase);
//ei.set_expression(arg);
}
else
{
char* buf = new char[std::strlen(arg) + 8];
std::sprintf(buf, "\\<%s\\>", arg);
e.set_expression(buf, use_case ? regbase::normal : regbase::normal | regbase::icase);
e.set_expression(buf, use_case ? regex::normal : regbase::normal | regbase::icase);
//ei.set_expression(buf);
delete[] buf;
}
@ -261,7 +261,7 @@ void HandleArg(const char* arg)
}
if(words_only)
std::strcat(buf2, "\\>");
e.set_expression(buf2, use_case ? regbase::normal : regbase::normal | regbase::icase);
e.set_expression(buf2, use_case ? regex::normal : regbase::normal | regbase::icase);
//ei.set_expression(buf2);
delete[] buf2;
}

View File

@ -35,12 +35,12 @@ const std::string human_format("\\1-\\2-\\3-\\4");
std::string machine_readable_card_number(const std::string& s)
{
return boost::regex_merge(s, e, machine_format, boost::match_default | boost::format_sed);
return boost::regex_replace(s, e, machine_format, boost::match_default | boost::format_sed);
}
std::string human_readable_card_number(const std::string& s)
{
return boost::regex_merge(s, e, human_format, boost::match_default | boost::format_sed);
return boost::regex_replace(s, e, human_format, boost::match_default | boost::format_sed);
}
#include <iostream>

View File

@ -0,0 +1,137 @@
/*
*
* Copyright (c) 1998-2002
* Dr John Maddock
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Dr John Maddock makes no representations
* about the suitability of this software for any purpose.
* It is provided "as is" without express or implied warranty.
*
*/
/*
* LOCATION: see http://www.boost.org for most recent version.
* FILE regex_replace_example.cpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: regex_replace example:
* converts a C++ file to syntax highlighted HTML.
*/
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <iterator>
#include <boost/regex.hpp>
#include <fstream>
#include <iostream>
// purpose:
// takes the contents of a file and transform to
// syntax highlighted code in html format
boost::regex e1, e2;
extern const char* expression_text;
extern const char* format_string;
extern const char* pre_expression;
extern const char* pre_format;
extern const char* header_text;
extern const char* footer_text;
void load_file(std::string& s, std::istream& is)
{
s.erase();
s.reserve(is.rdbuf()->in_avail());
char c;
while(is.get(c))
{
if(s.capacity() == s.size())
s.reserve(s.capacity() * 3);
s.append(1, c);
}
}
int main(int argc, const char** argv)
{
try{
e1.assign(expression_text);
e2.assign(pre_expression);
for(int i = 1; i < argc; ++i)
{
std::cout << "Processing file " << argv[i] << std::endl;
std::ifstream fs(argv[i]);
std::string in;
load_file(in, fs);
std::string out_name = std::string(argv[i]) + std::string(".htm");
std::ofstream os(out_name.c_str());
os << header_text;
// strip '<' and '>' first by outputting to a
// temporary string stream
std::ostringstream t(std::ios::out | std::ios::binary);
std::ostream_iterator<char> oi(t);
boost::regex_replace(oi, in.begin(), in.end(), e2, pre_format);
// then output to final output stream
// adding syntax highlighting:
std::string s(t.str());
std::ostream_iterator<char> out(os);
boost::regex_replace(out, s.begin(), s.end(), e1, format_string);
os << footer_text;
}
}
catch(...)
{ return -1; }
return 0;
}
extern const char* pre_expression = "(<)|(>)|\\r";
extern const char* pre_format = "(?1&lt;)(?2&gt;)";
const char* expression_text = // preprocessor directives: index 1
"(^[[:blank:]]*#(?:[^\\\\\\n]|\\\\[^\\n[:punct:][:word:]]*[\\n[:punct:][:word:]])*)|"
// comment: index 2
"(//[^\\n]*|/\\*.*?\\*/)|"
// literals: index 3
"\\<([+-]?(?:(?:0x[[:xdigit:]]+)|(?:(?:[[:digit:]]*\\.)?[[:digit:]]+(?:[eE][+-]?[[:digit:]]+)?))u?(?:(?:int(?:8|16|32|64))|L)?)\\>|"
// string literals: index 4
"('(?:[^\\\\']|\\\\.)*'|\"(?:[^\\\\\"]|\\\\.)*\")|"
// keywords: index 5
"\\<(__asm|__cdecl|__declspec|__export|__far16|__fastcall|__fortran|__import"
"|__pascal|__rtti|__stdcall|_asm|_cdecl|__except|_export|_far16|_fastcall"
"|__finally|_fortran|_import|_pascal|_stdcall|__thread|__try|asm|auto|bool"
"|break|case|catch|cdecl|char|class|const|const_cast|continue|default|delete"
"|do|double|dynamic_cast|else|enum|explicit|extern|false|float|for|friend|goto"
"|if|inline|int|long|mutable|namespace|new|operator|pascal|private|protected"
"|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_cast"
"|struct|switch|template|this|throw|true|try|typedef|typeid|typename|union|unsigned"
"|using|virtual|void|volatile|wchar_t|while)\\>"
;
const char* format_string = "(?1<font color=\"#008040\">$&</font>)"
"(?2<I><font color=\"#000080\">$&</font></I>)"
"(?3<font color=\"#0000A0\">$&</font>)"
"(?4<font color=\"#0000FF\">$&</font>)"
"(?5<B>$&</B>)";
const char* header_text = "<HTML>\n<HEAD>\n"
"<TITLE>Auto-generated html formated source</TITLE>\n"
"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=windows-1252\">\n"
"</HEAD>\n"
"<BODY LINK=\"#0000ff\" VLINK=\"#800080\" BGCOLOR=\"#ffffff\">\n"
"<P> </P>\n<PRE>";
const char* footer_text = "</PRE>\n</BODY>\n\n";

View File

@ -28,7 +28,7 @@
#include <boost/regex.hpp>
boost::regex e("<\\s*A\\s+[^>]*href\\s*=\\s*\"([^\"]*)\"",
boost::regbase::normal | boost::regbase::icase);
boost::regex::normal | boost::regbase::icase);
void load_file(std::string& s, std::istream& is)
{

205
faq.htm
View File

@ -1,205 +0,0 @@
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta name="Template"
content="C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\html.dot">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
<title>Regex++ - FAQ</title>
</head>
<body bgcolor="#FFFFFF" link="#0000FF" vlink="#800080">
<p>&nbsp; </p>
<table border="0" cellpadding="7" cellspacing="0" width="100%">
<tr>
<td valign="top"><h3><img src="../../c++boost.gif"
alt="C++ Boost" width="276" height="86"></h3>
</td>
<td valign="top"><h3 align="center">Regex++, FAQ.</h3>
<p align="left"><i>Copyright (c) 1998-2001 </i></p>
<p align="left"><i>Dr John Maddock</i></p>
<p align="left"><i>Permission to use, copy, modify,
distribute and sell this software and its documentation
for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and
that both that copyright notice and this permission
notice appear in supporting documentation. Dr John
Maddock makes no representations about the suitability of
this software for any purpose. It is provided &quot;as is&quot;
without express or implied warranty.</i></p>
</td>
</tr>
</table>
<p><font color="#FF0000">Q. Why does using parenthesis in a
regular expression change the result of a match?</font></p>
<p>Parentheses don't only mark; they determine what the best
match is as well. regex++ tries to follow 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>&quot;(0*)([0-9]*)&quot; against &quot;00123&quot; would produce
$1 = &quot;00&quot;
$2 = &quot;123&quot;</pre>
<p>where as</p>
<pre>&quot;0*([0-9)*&quot; against &quot;00123&quot; would produce
$1 = &quot;00123&quot;</pre>
<p>If you think about it, had $1 only matched the &quot;123&quot;,
this would be &quot;less good&quot; than the match &quot;00123&quot;
which is both further to the left and longer. If you want $1 to
match only the &quot;123&quot; part, then you need to use
something like:</p>
<pre>&quot;0*([1-9][0-9]*)&quot;</pre>
<p>as the expression.</p>
<p><font color="#FF0000">Q. Configure says that my compiler is
unable to merge template instances, what does this mean?</font> </p>
<p>A. When you compile template code, you can end up with the
same template instances in multiple translation units - this will
lead to link time errors unless your compiler/linker is smart
enough to merge these template instances into a single record in
the executable file. If you see this warning after running
configure, then you can still link to libregex++.a if: </p>
<ol>
<li>You use only the low-level template classes (reg_expression&lt;&gt;
match_results&lt;&gt; etc), from a single translation
unit, and use no other part of regex++.</li>
<li>You use only the POSIX API functions (regcomp regexec etc),
and no other part of regex++.</li>
<li>You use only the high level class RegEx, and no other
part of regex++. </li>
</ol>
<p>Another option is to create a master include file, which
#include's all the regex++ source files, and all the source files
in which you use regex++. You then compile and link this master
file as a single translation unit. </p>
<p><font color="#FF0000">Q. Configure says that my compiler is
unable to merge template instances from archive files, what does
this mean?</font> </p>
<p>A. When you compile template code, you can end up with the
same template instances in multiple translation units - this will
lead to link time errors unless your compiler/linker is smart
enough to merge these template instances into a single record in
the executable file. Some compilers are able to do this for
normal .cpp or .o files, but fail if the object file has been
placed in a library archive. If you see this warning after
running configure, then you can still link to libregex++.a if: </p>
<ol>
<li>You use only the low-level template classes (reg_expression&lt;&gt;
match_results&lt;&gt; etc), and use no other part of
regex++.</li>
<li>You use only the POSIX API functions (regcomp regexec etc),
and no other part of regex++.</li>
<li>You use only the high level class RegEx, and no other
part of regex++. </li>
</ol>
<p>Another option is to add the regex++ source files directly to
your project instead of linking to libregex++.a, generally you
should do this only if you are getting link time errors with
libregex++.a. </p>
<p><font color="#FF0000">Q. Configure says that my compiler can't
merge templates containing switch statements, what does this
mean?</font> </p>
<p>A. Some compilers can't merge templates that contain static
data - this includes switch statements which implicitly generate
static data as well as code. Principally this affects the egcs
compiler - but note gcc 2.81 also suffers from this problem - the
compiler will compile and link the code - but the code will not
run because the code and the static data it uses have become
separated. The default behaviour of regex++ is to try and fix
this problem by declaring &quot;problem&quot; templates inside
unnamed namespaces, so that the templates have internal linkage.
Note that this can result in a great deal of code bloat. If the
compiler doesn't support namespaces, or if code bloat becomes a
problem, then follow the guidelines above for placing all the
templates used in a single translation unit, and edit boost/regex/config.hpp
so that BOOST_REGEX_NO_TEMPLATE_SWITCH_MERGE is no longer defined.
</p>
<p><font color="#FF0000">Q. I can't get regex++ to work with
escape characters, what's going on?</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 &quot;\\d+&quot;
in your code. Likewise to match a literal backslash you will need
to embed &quot;\\\\&quot; in your code. </p>
<p><font color="#FF0000">Q. Why don't character ranges work
properly?</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 &quot;C&quot; or
&quot;POSIX&quot;, [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 regex++ is to
turn locale sensitive collation off by setting the regbase::nocollate
compile time flag (this is set by regbase::normal). However if
you set a non-default compile time flag - for example regbase::extended
or regbase::basic, then locale dependent collation will be
enabled, this also applies to the POSIX API functions which use
either regbase::extended or regbase::basic internally, in the
latter case use REG_NOCOLLATE in combination with either
REG_BASIC or REG_EXTENDED when invoking regcomp if you don't want
locale sensitive collation. <i>[Note - when regbase::nocollate in
effect, the library behaves &quot;as if&quot; the LC_COLLATE
locale category were always &quot;C&quot;, regardless of what its
actually set to - end note</i>]. </p>
<p><font color="#FF0000">&nbsp;Q. Why can't I use the &quot;convenience&quot;
versions of query_match/reg_search/reg_grep/reg_format/reg_merge?</font>
</p>
<p>A. These versions may or may not be available depending upon
the capabilities of your compiler, the rules determining the
format of these functions are quite complex - and only the
versions visible to a standard compliant compiler are given in
the help. To find out what your compiler supports, run &lt;boost/regex.hpp&gt;
through your C++ pre-processor, and search the output file for
the function that you are interested in. </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 reg_expression
when compiling a regular expression, std::runtime_error can be
thrown when a call to reg_expression::imbue tries to open a
message catalogue that doesn't exist or when a call to RegEx::GrepFiles
or RegEx::FindFiles tries to open a file that cannot be opened,
finally std::bad_alloc can be thrown by just about any of the
functions in this library. </p>
<hr>
<p><i>Copyright </i><a href="mailto:John_Maddock@compuserve.com"><i>Dr
John Maddock</i></a><i> 1998-2000 all rights reserved.</i> </p>
</body>
</html>

View File

@ -1,243 +0,0 @@
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta name="Template"
content="C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\html.dot">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
<title>Regex++, Format String Reference</title>
</head>
<body bgcolor="#FFFFFF" link="#0000FF" vlink="#800080">
<p>&nbsp; </p>
<table border="0" cellpadding="7" cellspacing="0" width="100%">
<tr>
<td valign="top"><h3><img src="../../c++boost.gif"
alt="C++ Boost" width="276" height="86"></h3>
</td>
<td valign="top"><h3 align="center">Regex++, Format
String Reference.</h3>
<p align="left"><i>Copyright (c) 1998-2001 </i></p>
<p align="left"><i>Dr John Maddock</i></p>
<p align="left"><i>Permission to use, copy, modify,
distribute and sell this software and its documentation
for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and
that both that copyright notice and this permission
notice appear in supporting documentation. Dr John
Maddock makes no representations about the suitability of
this software for any purpose. It is provided &quot;as is&quot;
without express or implied warranty.</i></p>
</td>
</tr>
</table>
<hr>
<h3><a name="format_string"></a>Format String Syntax</h3>
<p>Format strings are used by the algorithms <a
href="template_class_ref.htm#reg_format">regex_format</a> and <a
href="template_class_ref.htm#reg_merge">regex_merge</a>, and are
used to transform one string into another. </p>
<p>There are three kind of format string: sed, perl and extended,
the extended syntax is the default so this is covered first. </p>
<p><b><i>Extended format syntax</i></b> </p>
<p>In format strings, all characters are treated as literals
except: ()$\?: </p>
<p>To use any of these as literals you must prefix them with the
escape character \ </p>
<p>The following special sequences are recognized: <br>
&nbsp; <br>
&nbsp; </p>
<p><i>Grouping:</i> </p>
<p>Use the parenthesis characters ( and ) to group sub-expressions
within the format string, use \( and \) to represent literal '('
and ')'. <br>
&nbsp; <br>
&nbsp; </p>
<p><i>Sub-expression expansions:</i> </p>
<p>The following perl like expressions expand to a particular
matched sub-expression: <br>
&nbsp; </p>
<table border="0" cellpadding="7" cellspacing="0" width="100%">
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">$`</td>
<td valign="top" width="43%">Expands to all the text from
the end of the previous match to the start of the current
match, if there was no previous match in the current
operation, then everything from the start of the input
string to the start of the match.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">$'</td>
<td valign="top" width="43%">Expands to all the text from
the end of the match to the end of the input string.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">$&amp;</td>
<td valign="top" width="43%">Expands to all of the
current match.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">$0</td>
<td valign="top" width="43%">Expands to all of the
current match.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">$N</td>
<td valign="top" width="43%">Expands to the text that
matched sub-expression <i>N</i>.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
</table>
<p><br>
&nbsp; </p>
<p><i>Conditional expressions:</i> </p>
<p>Conditional expressions allow two different format strings to
be selected dependent upon whether a sub-expression participated
in the match or not: </p>
<p>?Ntrue_expression:false_expression </p>
<p>Executes true_expression if sub-expression <i>N</i>
participated in the match, otherwise executes false_expression. </p>
<p>Example: suppose we search for &quot;(while)|(for)&quot; then
the format string &quot;?1WHILE:FOR&quot; would output what
matched, but in upper case. <br>
&nbsp; <br>
&nbsp; </p>
<p><i>Escape sequences:</i> </p>
<p>The following escape sequences are also allowed: <br>
&nbsp; </p>
<table border="0" cellpadding="7" cellspacing="0" width="100%">
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">\a</td>
<td valign="top" width="43%">The bell character.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">\f</td>
<td valign="top" width="43%">The form feed character.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">\n</td>
<td valign="top" width="43%">The newline character.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">\r</td>
<td valign="top" width="43%">The carriage return
character.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">\t</td>
<td valign="top" width="43%">The tab character.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">\v</td>
<td valign="top" width="43%">A vertical tab character.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">\x</td>
<td valign="top" width="43%">A hexadecimal character -
for example \x0D.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">\x{}</td>
<td valign="top" width="43%">A possible unicode
hexadecimal character - for example \x{1A0}</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">\cx</td>
<td valign="top" width="43%">The ASCII escape character
x, for example \c@ is equivalent to escape-@.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">\e</td>
<td valign="top" width="43%">The ASCII escape character.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="8%">&nbsp;</td>
<td valign="top" width="40%">\dd</td>
<td valign="top" width="43%">An octal character constant,
for example \10.</td>
<td valign="top" width="9%">&nbsp;</td>
</tr>
</table>
<p><br>
&nbsp; </p>
<p><b><i>Perl format strings</i></b> </p>
<p>Perl format strings are the same as the default syntax except
that the characters ()?: have no special meaning. </p>
<p><b><i>Sed format strings</i></b> </p>
<p>Sed format strings use only the characters \ and &amp; as
special characters. </p>
<p>\n where n is a digit, is expanded to the nth sub-expression. </p>
<p>&amp; is expanded to the whole of the match (equivalent to \0).
</p>
<p>Other escape sequences are expanded as per the default syntax.
<br>
</p>
<hr>
<p><i>Copyright </i><a href="mailto:John_Maddock@compuserve.com"><i>Dr
John Maddock</i></a><i> 1998-2000 all rights reserved.</i> </p>
</body>
</html>

View File

@ -1,572 +0,0 @@
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta name="Template"
content="C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\html.dot">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
<title>Regex++, RegEx Class Reference</title>
</head>
<body bgcolor="#FFFFFF" link="#0000FF" vlink="#800080">
<p>&nbsp; </p>
<table border="0" cellpadding="7" cellspacing="0" width="100%">
<tr>
<td valign="top"><h3><img src="../../c++boost.gif"
alt="C++ Boost" width="276" height="86"></h3>
</td>
<td valign="top"><h3 align="center">Regex++, RegEx Class
Reference. </h3>
<p align="left"><i>Copyright (c) 1998-2001 </i></p>
<p align="left"><i>Dr John Maddock</i></p>
<p align="left"><i>Permission to use, copy, modify,
distribute and sell this software and its documentation
for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and
that both that copyright notice and this permission
notice appear in supporting documentation. Dr John
Maddock makes no representations about the suitability of
this software for any purpose. It is provided &quot;as is&quot;
without express or implied warranty.</i></p>
</td>
</tr>
</table>
<hr>
<h3><a name="RegEx"></a><i>Class RegEx</i></h3>
<p>#include &lt;boost/cregex.hpp&gt; </p>
<p>The class RegEx provides a high level simplified interface to
the regular expression library, this class only handles narrow
character strings, and regular expressions always follow the
&quot;normal&quot; syntax - that is the same as the standard
POSIX extended syntax, but with locale specific collation
disabled, and escape characters inside character set declarations
are allowed. </p>
<pre><b>typedef</b> <b>bool</b> (*GrepCallback)(<b>const</b> RegEx&amp; expression);
<b>typedef</b> <b>bool</b> (*GrepFileCallback)(<b>const</b> <b>char</b>* file, <b>const</b> RegEx&amp; expression);
<b>typedef</b> <b>bool</b> (*FindFilesCallback)(<b>const</b> <b>char</b>* file);
<b>class</b>&nbsp; RegEx
{
<b>public</b>:
&nbsp;&nbsp; RegEx();
&nbsp;&nbsp; RegEx(<b>const</b> RegEx&amp; o);
&nbsp;&nbsp; ~RegEx();
&nbsp;&nbsp; RegEx(<b>const</b> <b>char</b>* c, <b>bool</b> icase = <b>false</b>);
&nbsp;&nbsp; <strong>explicit</strong> RegEx(<b>const</b> std::string&amp; s, <b>bool</b> icase = <b>false</b>);
&nbsp;&nbsp; RegEx&amp; <b>operator</b>=(<b>const</b> RegEx&amp; o);
&nbsp;&nbsp; RegEx&amp; <b>operator</b>=(<b>const</b> <b>char</b>* p);
&nbsp;&nbsp; RegEx&amp; <b>operator</b>=(<b>const</b> std::string&amp; s);
&nbsp;&nbsp; <b>unsigned</b> <b>int</b> SetExpression(<b>const</b> <b>char</b>* p, <b>bool</b> icase = <b>false</b>);
&nbsp;&nbsp; <b>unsigned</b> <b>int</b> SetExpression(<b>const</b> std::string&amp; s, <b>bool</b> icase = <b>false</b>);
&nbsp;&nbsp; std::string Expression()<b>const</b>;
&nbsp;&nbsp; <font color="#000080"><i>//
</i>&nbsp;&nbsp;<i>// now matching operators: </i>
&nbsp;&nbsp; <i>// </i></font>
&nbsp;&nbsp; <b>bool</b> Match(<b>const</b> <b>char</b>* p, <b>unsigned</b> <b>int</b> flags = match_default);
&nbsp;&nbsp; <b>bool</b> Match(<b>const</b> std::string&amp; s, <b>unsigned</b> <b>int</b> flags = match_default);
&nbsp;&nbsp; <b>bool</b> Search(<b>const</b> <b>char</b>* p, <b>unsigned</b> <b>int</b> flags = match_default);
&nbsp;&nbsp; <b>bool</b> Search(<b>const</b> std::string&amp; s, <b>unsigned</b> <b>int</b> flags = match_default);
&nbsp;&nbsp; <b>unsigned</b> <b>int</b> Grep(GrepCallback cb, <b>const</b> <b>char</b>* p, <b>unsigned</b> <b>int</b> flags = match_default);
&nbsp;&nbsp; <b>unsigned</b> <b>int</b> Grep(GrepCallback cb, <b>const</b> std::string&amp; s, <b>unsigned</b> <b>int</b> flags = match_default);
&nbsp;&nbsp; <b>unsigned</b> <b>int</b> Grep(std::vector&lt;std::string&gt;&amp; v, <b>const</b> <b>char</b>* p, <b>unsigned</b> <b>int</b> flags = match_default);
&nbsp;&nbsp; <b>unsigned</b> <b>int</b> Grep(std::vector&lt;std::string&gt;&amp; v, <b>const</b> std::string&amp; s, <b>unsigned</b> <b>int</b> flags = match_default);
&nbsp;&nbsp; <b>unsigned</b> <b>int</b> Grep(std::vector&lt;<b>unsigned</b> <b>int</b>&gt;&amp; v, <b>const</b> <b>char</b>* p, <b>unsigned</b> <b>int</b> flags = match_default);
&nbsp;&nbsp; <b>unsigned</b> <b>int</b> Grep(std::vector&lt;<b>unsigned</b> <b>int</b>&gt;&amp; v, <b>const</b> std::string&amp; s, <b>unsigned</b> <b>int</b> flags = match_default);
&nbsp;&nbsp; <b>unsigned</b> <b>int</b> GrepFiles(GrepFileCallback cb, <b>const</b> <b>char</b>* files, <b>bool</b> recurse = <b>false</b>, <b>unsigned</b> <b>int</b> flags = match_default);
&nbsp;&nbsp; <b>unsigned</b> <b>int</b> GrepFiles(GrepFileCallback cb, <b>const</b> std::string&amp; files, <b>bool</b> recurse = <b>false</b>, <b>unsigned</b> <b>int</b> flags = match_default);
&nbsp;&nbsp; <b>unsigned</b> <b>int</b> FindFiles(FindFilesCallback cb, <b>const</b> <b>char</b>* files, <b>bool</b> recurse = <b>false</b>, <b>unsigned</b> <b>int</b> flags = match_default);
&nbsp;&nbsp; <b>unsigned</b> <b>int</b> FindFiles(FindFilesCallback cb, <b>const</b> std::string&amp; files, <b>bool</b> recurse = <b>false</b>, <b>unsigned</b> <b>int</b> flags = match_default);
&nbsp;&nbsp; std::string Merge(<b>const</b> std::string&amp; in, <b>const</b> std::string&amp; fmt, <b>bool</b> copy = <b>true</b>, <b>unsigned</b> <b>int</b> flags = match_default);
&nbsp;&nbsp; std::string Merge(<b>const</b> char* in, <b>const</b> char* fmt, <b>bool</b> copy = <b>true</b>, <b>unsigned int </b>flags = match_default);
&nbsp;&nbsp; <b>unsigned</b> Split(std::vector&lt;std::string&gt;&amp; v, std::string&amp; s, <b>unsigned</b> flags = match_default, <b>unsigned</b> max_count = ~0);
&nbsp;&nbsp; <font color="#000080"><i>//
</i>&nbsp;&nbsp; <i>// now operators for returning what matched in more detail:
</i>&nbsp;&nbsp; <i>//
</i></font>&nbsp;&nbsp; <b>unsigned</b> <b>int</b> Position(<b>int</b> i = 0)<b>const</b>;
&nbsp;&nbsp; <b>unsigned</b> <b>int</b> Length(<b>int</b> i = 0)<b>const</b>;
<strong>bool</strong> Matched(<strong>int</strong> i = 0)<strong>const</strong>;
&nbsp;&nbsp; <b>unsigned</b> <b>int</b> Line()<b>const</b>;
&nbsp;&nbsp; <b>unsigned int</b> Marks() const;
&nbsp;&nbsp; std::string What(<b>int</b> i)<b>const</b>;
&nbsp;&nbsp; std::string <b>operator</b>[](<b>int</b> i)<b>const</b> ;
<strong>static const unsigned int</strong> npos;
}; &nbsp; &nbsp; </pre>
<p>Member functions for class RegEx are defined as follows: <br>
&nbsp; </p>
<table border="0" cellpadding="7" cellspacing="0" width="100%">
<tr>
<td valign="top" width="7%">&nbsp;</td>
<td valign="top" width="43%">RegEx();</td>
<td valign="top" width="42%">Default constructor,
constructs an instance of RegEx without any valid
expression.</td>
<td valign="top" width="7%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="7%">&nbsp;</td>
<td valign="top" width="43%">RegEx(<b>const</b>
RegEx&amp; o);</td>
<td valign="top" width="42%">Copy constructor, all the
properties of parameter <i>o</i> are copied.</td>
<td valign="top" width="7%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="7%">&nbsp;</td>
<td valign="top" width="43%">RegEx(<b>const</b> <b>char</b>*
c, <b>bool</b> icase = <b>false</b>);</td>
<td valign="top" width="42%">Constructs an instance of
RegEx, setting the expression to <i>c</i>, if <i>icase</i>
is <i>true</i> then matching is insensitive to case,
otherwise it is sensitive to case. Throws <i>bad_expression</i>
on failure.</td>
<td valign="top" width="7%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="7%">&nbsp;</td>
<td valign="top" width="43%">RegEx(<b>const</b> std::string&amp;
s, <b>bool</b> icase = <b>false</b>);</td>
<td valign="top" width="42%">Constructs an instance of
RegEx, setting the expression to <i>s</i>, if <i>icase </i>is
<i>true</i> then matching is insensitive to case,
otherwise it is sensitive to case. Throws <i>bad_expression</i>
on failure.</td>
<td valign="top" width="7%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="7%">&nbsp;</td>
<td valign="top" width="43%">RegEx&amp; <b>operator</b>=(<b>const</b>
RegEx&amp; o);</td>
<td valign="top" width="42%">Default assignment operator.</td>
<td valign="top" width="7%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="7%">&nbsp;</td>
<td valign="top" width="43%">RegEx&amp; <b>operator</b>=(<b>const</b>
<b>char</b>* p);</td>
<td valign="top" width="42%">Assignment operator,
equivalent to calling <i>SetExpression(p, false).</i>
Throws <i>bad_expression</i> on failure.</td>
<td valign="top" width="7%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="7%">&nbsp;</td>
<td valign="top" width="43%">RegEx&amp; <b>operator</b>=(<b>const</b>
std::string&amp; s);</td>
<td valign="top" width="42%">Assignment operator,
equivalent to calling <i>SetExpression(s, false).</i>
Throws <i>bad_expression</i> on failure.</td>
<td valign="top" width="7%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="7%">&nbsp;</td>
<td valign="top" width="43%"><b>unsigned</b> <b>int</b>
SetExpression(<b>constchar</b>* p, <b>bool</b> icase = <b>false</b>);</td>
<td valign="top" width="42%">Sets the current expression
to <i>p</i>, if <i>icase</i> is <i>true</i> then matching
is insensitive to case, otherwise it is sensitive to case.
Throws <i>bad_expression</i> on failure.</td>
<td valign="top" width="7%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="7%">&nbsp;</td>
<td valign="top" width="43%"><b>unsigned</b> <b>int</b>
SetExpression(<b>const</b> std::string&amp; s, <b>bool</b>
icase = <b>false</b>);</td>
<td valign="top" width="42%">Sets the current expression
to <i>s</i>, if <i>icase</i> is <i>true</i> then matching
is insensitive to case, otherwise it is sensitive to case.
Throws <i>bad_expression</i> on failure.</td>
<td valign="top" width="7%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="7%">&nbsp;</td>
<td valign="top" width="43%">std::string Expression()<b>const</b>;</td>
<td valign="top" width="42%">Returns a copy of the
current regular expression.</td>
<td valign="top" width="7%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="7%">&nbsp;</td>
<td valign="top" width="43%"><b>bool</b> Match(<b>const</b>
<b>char</b>* p, <b>unsigned</b> <b>int</b> flags =
match_default);</td>
<td valign="top" width="42%">Attempts to match the
current expression against the text <i>p</i> using the
match flags <i>flags</i> - see <a
href="template_class_ref.htm#match_type">match flags</a>.
Returns <i>true</i> if the expression matches the whole
of the input string.</td>
<td valign="top" width="7%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="7%">&nbsp;</td>
<td valign="top" width="43%"><b>bool</b> Match(<b>const</b>
std::string&amp; s, <b>unsigned</b> <b>int</b> flags =
match_default) ;</td>
<td valign="top" width="42%">Attempts to match the
current expression against the text <i>s</i> using the
match flags <i>flags</i> - see <a
href="template_class_ref.htm#match_type">match flags</a>.
Returns <i>true</i> if the expression matches the whole
of the input string.</td>
<td valign="top" width="7%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="7%">&nbsp;</td>
<td valign="top" width="43%"><b>bool</b> Search(<b>const</b>
<b>char</b>* p, <b>unsigned</b> <b>int</b> flags =
match_default);</td>
<td valign="top" width="42%">Attempts to find a match for
the current expression somewhere in the text <i>p</i>
using the match flags <i>flags </i>- see <a
href="template_class_ref.htm#match_type">match flags</a>.
Returns <i>true</i> if the match succeeds.</td>
<td valign="top" width="7%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="7%">&nbsp;</td>
<td valign="top" width="43%"><b>bool</b> Search(<b>const</b>
std::string&amp; s, <b>unsigned</b> <b>int</b> flags =
match_default) ;</td>
<td valign="top" width="42%">Attempts to find a match for
the current expression somewhere in the text <i>s</i>
using the match flags <i>flags </i>- see <a
href="template_class_ref.htm#match_type">match flags</a>.
Returns <i>true</i> if the match succeeds.</td>
<td valign="top" width="7%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="7%">&nbsp;</td>
<td valign="top" width="43%"><b>unsigned</b> <b>int</b>
Grep(GrepCallback cb, <b>const</b> <b>char</b>* p, <b>unsigned</b>
<b>int</b> flags = match_default);</td>
<td valign="top" width="42%">Finds all matches of the
current expression in the text <i>p</i> using the match
flags <i>flags </i>- see <a
href="template_class_ref.htm#match_type">match flags</a>.
For each match found calls the call-back function <i>cb</i>
as: cb(*this); <p>If at any stage the call-back function
returns false then the grep operation terminates,
otherwise continues until no further matches are found.
Returns the number of matches found.</p>
</td>
<td valign="top" width="7%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="7%">&nbsp;</td>
<td valign="top" width="43%"><b>unsigned</b> <b>int</b>
Grep(GrepCallback cb, <b>const</b> std::string&amp; s, <b>unsigned</b>
<b>int</b> flags = match_default);</td>
<td valign="top" width="42%">Finds all matches of the
current expression in the text <i>s</i> using the match
flags <i>flags </i>- see <a
href="template_class_ref.htm#match_type">match flags</a>.
For each match found calls the call-back function <i>cb</i>
as: cb(*this); <p>If at any stage the call-back function
returns false then the grep operation terminates,
otherwise continues until no further matches are found.
Returns the number of matches found. </p>
</td>
<td valign="top" width="7%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="7%">&nbsp;</td>
<td valign="top" width="43%"><b>unsigned</b> <b>int</b>
Grep(std::vector&lt;std::string&gt;&amp; v, <b>const</b> <b>char</b>*
p, <b>unsigned</b> <b>int</b> flags = match_default);</td>
<td valign="top" width="42%">Finds all matches of the
current expression in the text <i>p</i> using the match
flags <i>flags </i>- see <a
href="template_class_ref.htm#match_type">match flags</a>.
For each match pushes a copy of what matched onto <i>v</i>.
Returns the number of matches found.</td>
<td valign="top" width="7%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="7%">&nbsp;</td>
<td valign="top" width="43%"><b>unsigned</b> <b>int</b>
Grep(std::vector&lt;std::string&gt;&amp; v, <b>const</b>
std::string&amp; s, <b>unsigned</b> <b>int</b> flags =
match_default);</td>
<td valign="top" width="42%">Finds all matches of the
current expression in the text <i>s</i> using the match
flags <i>flags </i>- see <a
href="template_class_ref.htm#match_type">match flags</a>.
For each match pushes a copy of what matched onto <i>v</i>.
Returns the number of matches found.</td>
<td valign="top" width="7%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="7%">&nbsp;</td>
<td valign="top" width="43%"><b>unsigned</b> <b>int</b>
Grep(std::vector&lt;<b>unsigned int</b>&gt;&amp; v, <b>const</b>
<b>char</b>* p, <b>unsigned</b> <b>int</b> flags =
match_default);</td>
<td valign="top" width="42%">Finds all matches of the
current expression in the text <i>p</i> using the match
flags <i>flags </i>- see <a
href="template_class_ref.htm#match_type">match flags</a>.
For each match pushes the starting index of what matched
onto <i>v</i>. Returns the number of matches found.</td>
<td valign="top" width="7%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="7%">&nbsp;</td>
<td valign="top" width="43%"><b>unsigned</b> <b>int</b>
Grep(std::vector&lt;<b>unsigned int</b>&gt;&amp; v, <b>const</b>
std::string&amp; s, <b>unsigned</b> <b>int</b> flags =
match_default);</td>
<td valign="top" width="42%">Finds all matches of the
current expression in the text <i>s</i> using the match
flags <i>flags </i>- see <a
href="template_class_ref.htm#match_type">match flags</a>.
For each match pushes the starting index of what matched
onto <i>v</i>. Returns the number of matches found.</td>
<td valign="top" width="7%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="7%">&nbsp;</td>
<td valign="top" width="43%"><b>unsigned</b> <b>int</b>
GrepFiles(GrepFileCallback cb, <b>const</b> <b>char</b>*
files, <b>bool</b> recurse = <b>false</b>, <b>unsigned</b>
<b>int</b> flags = match_default);</td>
<td valign="top" width="42%">Finds all matches of the
current expression in the files <i>files</i> using the
match flags <i>flags </i>- see <a
href="template_class_ref.htm#match_type">match flags</a>.
For each match calls the call-back function cb.&nbsp; <p>If
the call-back returns false then the algorithm returns
without considering further matches in the current file,
or any further files.&nbsp; </p>
<p>The parameter <i>files</i> can include wild card
characters '*' and '?', if the parameter <i>recurse</i>
is true then searches sub-directories for matching file
names.&nbsp; </p>
<p>Returns the total number of matches found.</p>
<p>May throw an exception derived from std::runtime_error
if file io fails.</p>
</td>
<td valign="top" width="7%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="7%">&nbsp;</td>
<td valign="top" width="43%"><b>unsigned</b> <b>int</b>
GrepFiles(GrepFileCallback cb, <b>const</b> std::string&amp;
files, <b>bool</b> recurse = <b>false</b>, <b>unsigned</b>
<b>int</b> flags = match_default);</td>
<td valign="top" width="42%">Finds all matches of the
current expression in the files <i>files</i> using the
match flags <i>flags </i>- see <a
href="template_class_ref.htm#match_type">match flags</a>.
For each match calls the call-back function cb.&nbsp; <p>If
the call-back returns false then the algorithm returns
without considering further matches in the current file,
or any further files.&nbsp; </p>
<p>The parameter <i>files</i> can include wild card
characters '*' and '?', if the parameter <i>recurse</i>
is true then searches sub-directories for matching file
names.&nbsp; </p>
<p>Returns the total number of matches found.</p>
<p>May throw an exception derived from std::runtime_error
if file io fails.</p>
</td>
<td valign="top" width="7%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="7%">&nbsp;</td>
<td valign="top" width="43%"><b>unsigned</b> <b>int</b>
FindFiles(FindFilesCallback cb, <b>const</b> <b>char</b>*
files, <b>bool</b> recurse = <b>false</b>, <b>unsigned</b>
<b>int</b> flags = match_default);</td>
<td valign="top" width="42%">Searches <i>files</i> to
find all those which contain at least one match of the
current expression using the match flags <i>flags </i>-
see <a href="template_class_ref.htm#match_type">match
flags</a>. For each matching file calls the call-back
function cb.&nbsp; <p>If the call-back returns false then
the algorithm returns without considering any further
files.&nbsp; </p>
<p>The parameter <i>files</i> can include wild card
characters '*' and '?', if the parameter <i>recurse</i>
is true then searches sub-directories for matching file
names.&nbsp; </p>
<p>Returns the total number of files found.</p>
<p>May throw an exception derived from std::runtime_error
if file io fails.</p>
</td>
<td valign="top" width="7%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="7%">&nbsp;</td>
<td valign="top" width="43%"><b>unsigned</b> <b>int</b>
FindFiles(FindFilesCallback cb, <b>const</b> std::string&amp;
files, <b>bool</b> recurse = <b>false</b>, <b>unsigned</b>
<b>int</b> flags = match_default);</td>
<td valign="top" width="42%">Searches <i>files</i> to
find all those which contain at least one match of the
current expression using the match flags <i>flags </i>-
see <a href="template_class_ref.htm#match_type">match
flags</a>. For each matching file calls the call-back
function cb.&nbsp; <p>If the call-back returns false then
the algorithm returns without considering any further
files.&nbsp; </p>
<p>The parameter <i>files</i> can include wild card
characters '*' and '?', if the parameter <i>recurse</i>
is true then searches sub-directories for matching file
names.&nbsp; </p>
<p>Returns the total number of files found.</p>
<p>May throw an exception derived from std::runtime_error
if file io fails.</p>
</td>
<td valign="top" width="7%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="7%">&nbsp;</td>
<td valign="top" width="43%">std::string Merge(<b>const</b>
std::string&amp; in, <b>const</b> std::string&amp; fmt, <b>bool</b>
copy = <b>true</b>, <b>unsigned</b> <b>int</b> flags =
match_default);</td>
<td valign="top" width="42%">Performs a search and
replace operation: searches through the string <i>in</i>
for all occurrences of the current expression, for each
occurrence replaces the match with the format string <i>fmt</i>.
Uses <i>flags</i> to determine what gets matched, and how
the format string should be treated. If <i>copy</i> is
true then all unmatched sections of input are copied
unchanged to output, if the flag <em>format_first_only</em>
is set then only the first occurance of the pattern found
is replaced. Returns the new string. See <a
href="format_string.htm#format_string">also format string
syntax</a>, <a href="template_class_ref.htm#match_type">match
flags</a> and <a
href="template_class_ref.htm#format_flags">format flags</a>.</td>
<td valign="top" width="7%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="7%">&nbsp;</td>
<td valign="top" width="43%">std::string Merge(<b>const</b>
char* in, <b>const</b> char* fmt, <b>bool</b> copy = <b>true</b>,
<b>unsigned int </b>flags = match_default);</td>
<td valign="top" width="42%">Performs a search and
replace operation: searches through the string <i>in</i>
for all occurrences of the current expression, for each
occurrence replaces the match with the format string <i>fmt</i>.
Uses <i>flags</i> to determine what gets matched, and how
the format string should be treated. If <i>copy</i> is
true then all unmatched sections of input are copied
unchanged to output, if the flag <em>format_first_only</em>
is set then only the first occurance of the pattern found
is replaced. Returns the new string. See <a
href="format_string.htm#format_string">also format string
syntax</a>, <a href="template_class_ref.htm#match_type">match
flags</a> and <a
href="template_class_ref.htm#format_flags">format flags</a>.</td>
<td valign="top" width="7%">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td valign="top"><b>unsigned</b> Split(std::vector&lt;std::string&gt;&amp;
v, std::string&amp; s, <b>unsigned</b> flags =
match_default, <b>unsigned</b> max_count = ~0);</td>
<td valign="top">Splits the input string and pushes each
one onto the vector. If the expression contains no marked
sub-expressions, then one string is outputted for each
section of the input that does not match the expression.
If the expression does contain marked sub-expressions,
then outputs one string for each marked sub-expression
each time a match occurs. Outputs no more than <i>max_count
</i>strings. Before returning, deletes from the input
string <i>s</i> all of the input that has been processed
(all of the string if <i>max_count</i> was not reached).
Returns the number of strings pushed onto the vector.</td>
<td>&nbsp;</td>
</tr>
<tr>
<td valign="top" width="7%">&nbsp;</td>
<td valign="top" width="43%"><b>unsigned</b> <b>int</b>
Position(<b>int</b> i = 0)<b>const</b>;</td>
<td valign="top" width="42%">Returns the position of what
matched sub-expression <i>i</i>. If <i>i = 0</i> then
returns the position of the whole match. Returns RegEx::npos
if the supplied index is invalid, or if the specified sub-expression
did not participate in the match.</td>
<td valign="top" width="7%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="7%">&nbsp;</td>
<td valign="top" width="43%"><b>unsigned</b> <b>int</b>
Length(<b>int</b> i = 0)<b>const</b>;</td>
<td valign="top" width="42%">Returns the length of what
matched sub-expression <i>i</i>. If <i>i = 0</i> then
returns the length of the whole match. Returns RegEx::npos
if the supplied index is invalid, or if the specified sub-expression
did not participate in the match.</td>
<td valign="top" width="7%">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><strong>bool</strong> Matched(<strong>int</strong> i
= 0)<strong>const</strong>;</td>
<td>Returns true if sub-expression <em>i</em> was
matched, false otherwise.</td>
<td>&nbsp;</td>
</tr>
<tr>
<td valign="top" width="7%">&nbsp;</td>
<td valign="top" width="43%"><b>unsigned</b> <b>int</b>
Line()<b>const</b>;</td>
<td valign="top" width="42%">Returns the line on which
the match occurred, indexes start from 1 not zero, if no
match occurred then returns RegEx::npos.</td>
<td valign="top" width="7%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="7%">&nbsp;</td>
<td valign="top" width="43%"><b>unsigned int</b> Marks()
const;</td>
<td valign="top" width="42%">Returns the number of marked
sub-expressions contained in the expression. Note that
this includes the whole match (sub-expression zero), so
the value returned is always &gt;= 1.</td>
<td valign="top" width="7%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="7%">&nbsp;</td>
<td valign="top" width="43%">std::string What(<b>int</b>
i)<b>const</b>;</td>
<td valign="top" width="42%">Returns a copy of what
matched sub-expression <i>i</i>. If <i>i = 0</i> then
returns a copy of the whole match. Returns a null string
if the index is invalid or if the specified sub-expression
did not participate in a match.</td>
<td valign="top" width="7%">&nbsp;</td>
</tr>
<tr>
<td valign="top" width="7%">&nbsp;</td>
<td valign="top" width="43%">std::string <b>operator</b>[](<b>int</b>
i)<b>const</b> ;</td>
<td valign="top" width="42%">Returns <i>what(i);</i> <p>Can
be used to simplify access to sub-expression matches, and
make usage more perl-like.</p>
</td>
<td valign="top" width="7%">&nbsp;</td>
</tr>
</table>
<hr>
<p><i>Copyright </i><a href="mailto:John_Maddock@compuserve.com"><i>Dr
John Maddock</i></a><i> 1998-2000 all rights reserved.</i> </p>
</body>
</html>

View File

@ -64,7 +64,7 @@ public:
typedef typename Allocator::size_type size_type;
typedef Allocator allocator_type;
typedef Allocator alloc_type;
typedef regbase::flag_type flag_type;
typedef regex_constants::syntax_option_type flag_type;
// locale_type
// placeholder for actual locale type used by the
// traits class to localise *this.
@ -72,15 +72,15 @@ public:
public:
explicit reg_expression(const Allocator& a = Allocator());
explicit reg_expression(const charT* p, flag_type f = regbase::normal, const Allocator& a = Allocator());
reg_expression(const charT* p1, const charT* p2, flag_type f = regbase::normal, const Allocator& a = Allocator());
explicit reg_expression(const charT* p, flag_type f = regex_constants::normal, const Allocator& a = Allocator());
reg_expression(const charT* p1, const charT* p2, flag_type f = regex_constants::normal, const Allocator& a = Allocator());
reg_expression(const charT* p, size_type len, flag_type f, const Allocator& a = Allocator());
reg_expression(const reg_expression&);
~reg_expression();
reg_expression& BOOST_REGEX_CALL operator=(const reg_expression&);
reg_expression& BOOST_REGEX_CALL operator=(const charT* ptr)
{
set_expression(ptr, regbase::normal | regbase::use_except);
set_expression(ptr, regex_constants::normal | regex_constants::use_except);
return *this;
}
@ -88,84 +88,84 @@ public:
// assign:
reg_expression& assign(const reg_expression& that)
{ return *this = that; }
reg_expression& assign(const charT* ptr, flag_type f = regbase::normal)
reg_expression& assign(const charT* ptr, flag_type f = regex_constants::normal)
{
set_expression(ptr, f | regbase::use_except);
set_expression(ptr, f | regex_constants::use_except);
return *this;
}
reg_expression& assign(const charT* first,
const charT* last,
flag_type f = regbase::normal)
flag_type f = regex_constants::normal)
{
set_expression(first, last, f | regbase::use_except);
set_expression(first, last, f | regex_constants::use_except);
return *this;
}
#if !defined(BOOST_NO_MEMBER_TEMPLATES) && !(defined(__IBMCPP__) && (__IBMCPP__ <= 502))
template <class ST, class SA>
unsigned int BOOST_REGEX_CALL set_expression(const std::basic_string<charT, ST, SA>& p, flag_type f = regbase::normal)
unsigned int BOOST_REGEX_CALL set_expression(const std::basic_string<charT, ST, SA>& p, flag_type f = regex_constants::normal)
{ return set_expression(p.data(), p.data() + p.size(), f); }
template <class ST, class SA>
explicit reg_expression(const std::basic_string<charT, ST, SA>& p, flag_type f = regbase::normal, const Allocator& a = Allocator())
: data(a), pkmp(0), error_code_(REG_EMPTY), _expression(0) { set_expression(p, f | regbase::use_except); }
explicit reg_expression(const std::basic_string<charT, ST, SA>& p, flag_type f = regex_constants::normal, const Allocator& a = Allocator())
: data(a), pkmp(0), error_code_(REG_EMPTY), _expression(0) { set_expression(p, f | regex_constants::use_except); }
template <class I>
reg_expression(I first, I last, flag_type f = regbase::normal, const Allocator& al = Allocator())
reg_expression(I first, I last, flag_type f = regex_constants::normal, const Allocator& al = Allocator())
: data(al), pkmp(0), error_code_(REG_EMPTY), _expression(0)
{
size_type len = last-first;
scoped_array<charT> a(new charT[len]);
std::copy(first, last, a.get());
set_expression(a.get(), a.get() + len, f | regbase::use_except);
set_expression(a.get(), a.get() + len, f | regex_constants::use_except);
}
template <class ST, class SA>
reg_expression& BOOST_REGEX_CALL operator=(const std::basic_string<charT, ST, SA>& p)
{
set_expression(p.c_str(), p.c_str() + p.size(), regbase::normal | regbase::use_except);
set_expression(p.c_str(), p.c_str() + p.size(), regex_constants::normal | regex_constants::use_except);
return *this;
}
template <class string_traits, class A>
reg_expression& BOOST_REGEX_CALL assign(
const std::basic_string<charT, string_traits, A>& s,
flag_type f = regbase::normal)
flag_type f = regex_constants::normal)
{
set_expression(s.c_str(), s.c_str() + s.size(), f | regbase::use_except);
set_expression(s.c_str(), s.c_str() + s.size(), f | regex_constants::use_except);
return *this;
}
template <class fwd_iterator>
reg_expression& BOOST_REGEX_CALL assign(fwd_iterator first,
fwd_iterator last,
flag_type f = regbase::normal)
flag_type f = regex_constants::normal)
{
size_type len = last-first;
scoped_array<charT> a(new charT[len]);
std::copy(first, last, a.get());
set_expression(a.get(), a.get() + len, f | regbase::use_except);
set_expression(a.get(), a.get() + len, f | regex_constants::use_except);
return *this;
}
#else
unsigned int BOOST_REGEX_CALL set_expression(const std::basic_string<charT>& p, flag_type f = regbase::normal)
{ return set_expression(p.data(), p.data() + p.size(), f | regbase::use_except); }
unsigned int BOOST_REGEX_CALL set_expression(const std::basic_string<charT>& p, flag_type f = regex_constants::normal)
{ return set_expression(p.data(), p.data() + p.size(), f | regex_constants::use_except); }
reg_expression(const std::basic_string<charT>& p, flag_type f = regbase::normal, const Allocator& a = Allocator())
: data(a), pkmp(0) { set_expression(p, f | regbase::use_except); }
reg_expression(const std::basic_string<charT>& p, flag_type f = regex_constants::normal, const Allocator& a = Allocator())
: data(a), pkmp(0) { set_expression(p, f | regex_constants::use_except); }
reg_expression& BOOST_REGEX_CALL operator=(const std::basic_string<charT>& p)
{
set_expression(p.c_str(), p.c_str() + p.size(), regbase::normal | regbase::use_except);
set_expression(p.c_str(), p.c_str() + p.size(), regex_constants::normal | regex_constants::use_except);
return *this;
}
reg_expression& BOOST_REGEX_CALL assign(
const std::basic_string<charT>& s,
flag_type f = regbase::normal)
flag_type f = regex_constants::normal)
{
set_expression(s.c_str(), s.c_str() + s.size(), f | regbase::use_except);
set_expression(s.c_str(), s.c_str() + s.size(), f | regex_constants::use_except);
return *this;
}
@ -234,8 +234,8 @@ public:
// but are available for compatibility with earlier versions.
allocator_type BOOST_REGEX_CALL allocator()const;
const charT* BOOST_REGEX_CALL expression()const { return (this->error_code() ? 0 : _expression); }
unsigned int BOOST_REGEX_CALL set_expression(const charT* p, const charT* end, flag_type f = regbase::normal);
unsigned int BOOST_REGEX_CALL set_expression(const charT* p, flag_type f = regbase::normal) { return set_expression(p, p + traits_type::length(p), f); }
unsigned int BOOST_REGEX_CALL set_expression(const charT* p, const charT* end, flag_type f = regex_constants::normal);
unsigned int BOOST_REGEX_CALL set_expression(const charT* p, flag_type f = regex_constants::normal) { return set_expression(p, p + traits_type::length(p), f); }
//
// this should be private but template friends don't work:
const traits_type& get_traits()const { return traits_inst; }
@ -336,9 +336,9 @@ public:
typedef typename reg_expression<charT, traits, Allocator>::size_type size_type;
explicit basic_regex(const Allocator& a = Allocator())
: reg_expression<charT, traits, Allocator>(a){}
explicit basic_regex(const charT* p, flag_type f = regbase::normal, const Allocator& a = Allocator())
explicit basic_regex(const charT* p, flag_type f = regex_constants::normal, const Allocator& a = Allocator())
: reg_expression<charT, traits, Allocator>(p,f,a){}
basic_regex(const charT* p1, const charT* p2, flag_type f = regbase::normal, const Allocator& a = Allocator())
basic_regex(const charT* p1, const charT* p2, flag_type f = regex_constants::normal, const Allocator& a = Allocator())
: reg_expression<charT, traits, Allocator>(p1,p2,f,a){}
basic_regex(const charT* p, size_type len, flag_type f, const Allocator& a = Allocator())
: reg_expression<charT, traits, Allocator>(p,len,f,a){}
@ -357,11 +357,11 @@ public:
}
#if !defined(BOOST_NO_MEMBER_TEMPLATES) && !(defined(__IBMCPP__) && (__IBMCPP__ <= 502))
template <class ST, class SA>
explicit basic_regex(const std::basic_string<charT, ST, SA>& p, flag_type f = regbase::normal, const Allocator& a = Allocator())
explicit basic_regex(const std::basic_string<charT, ST, SA>& p, flag_type f = regex_constants::normal, const Allocator& a = Allocator())
: reg_expression<charT, traits, Allocator>(p,f,a){}
template <class I>
basic_regex(I first, I last, flag_type f = regbase::normal, const Allocator& al = Allocator())
basic_regex(I first, I last, flag_type f = regex_constants::normal, const Allocator& al = Allocator())
: reg_expression<charT, traits, Allocator>(first, last, f, a){}
template <class ST, class SA>
@ -371,7 +371,7 @@ public:
return *this;
}
#else
basic_regex(const std::basic_string<charT>& p, flag_type f = regbase::normal, const Allocator& a = Allocator())
basic_regex(const std::basic_string<charT>& p, flag_type f = regex_constants::normal, const Allocator& a = Allocator())
: reg_expression<charT, traits, Allocator>(p,f,a){}
basic_regex& BOOST_REGEX_CALL operator=(const std::basic_string<charT>& p)

View File

@ -29,6 +29,7 @@
#ifdef __cplusplus
namespace boost{
namespace regex_constants{
#endif
typedef enum _match_flags
@ -54,12 +55,14 @@ typedef enum _match_flags
match_all = match_stop << 1, // must find the whole of input even if match_any is set
match_perl = match_all << 1, // Use perl matching rules
match_posix = match_perl << 1, // Use POSIX matching rules
match_max = match_posix,
match_nosubs = match_posix << 1, // don't trap marked subs
match_max = match_nosubs,
format_all = 0, // enable all extentions to sytax
format_perl = 0, // perl style replacement
format_default = 0, // ditto.
format_sed = match_max << 1, // sed style replacement.
format_perl = format_sed << 1, // perl style replacement.
format_no_copy = format_perl << 1, // don't copy non-matching segments.
format_all = format_sed << 1, // enable all extentions to sytax.
format_no_copy = format_all << 1, // don't copy non-matching segments.
format_first_only = format_no_copy << 1, // Only replace first occurance.
format_is_if = format_first_only << 1 // internal use only.
@ -67,7 +70,6 @@ typedef enum _match_flags
#if defined(BOOST_MSVC) && (BOOST_MSVC <= 1200)
typedef unsigned long match_flag_type;
} // namespace boost
#else
typedef match_flags match_flag_type;
@ -87,10 +89,43 @@ inline match_flags& operator|=(match_flags& m1, match_flags m2)
{ m1 = m1|m2; return m1; }
inline match_flags& operator^=(match_flags& m1, match_flags m2)
{ m1 = m1^m2; return m1; }
#endif
#endif
#ifdef __cplusplus
} // namespace regex_constants
//
// import names into boost for backwards compatiblity:
//
using regex_constants::match_flag_type;
using regex_constants::match_default;
using regex_constants::match_not_bol;
using regex_constants::match_not_eol;
using regex_constants::match_not_bob;
using regex_constants::match_not_eob;
using regex_constants::match_not_bow;
using regex_constants::match_not_eow;
using regex_constants::match_not_dot_newline;
using regex_constants::match_not_dot_null;
using regex_constants::match_prev_avail;
using regex_constants::match_init;
using regex_constants::match_any;
using regex_constants::match_not_null;
using regex_constants::match_continuous;
using regex_constants::match_partial;
using regex_constants::match_stop;
using regex_constants::match_all;
using regex_constants::match_perl;
using regex_constants::match_posix;
using regex_constants::match_nosubs;
using regex_constants::match_max;
using regex_constants::format_all;
using regex_constants::format_sed;
using regex_constants::format_perl;
using regex_constants::format_no_copy;
using regex_constants::format_first_only;
using regex_constants::format_is_if;
} // namespace boost
#endif // __cplusplus
#endif // BOOST_MSVC
#endif
#endif // include guard

View File

@ -65,7 +65,7 @@ iterator BOOST_REGEX_CALL re_is_set_member(iterator next,
const charT* p = reinterpret_cast<const charT*>(set_+1);
iterator ptr;
unsigned int i;
bool icase = e.flags() & regbase::icase;
bool icase = e.flags() & regex_constants::icase;
if(next == last) return next;
@ -119,7 +119,7 @@ iterator BOOST_REGEX_CALL re_is_set_member(iterator next,
// try and match a range, NB only a single character can match
if(set_->cranges)
{
if(e.flags() & regbase::nocollate)
if((e.flags() & regex_constants::collate) == 0)
s1 = s2;
else
traits_inst.transform(s1, s2);

View File

@ -44,11 +44,11 @@ perl_matcher<BidiIterator, Allocator, traits, Allocator2>::perl_matcher(BidiIter
pstate = 0;
m_match_flags = f;
icase = re.flags() & regbase::icase;
icase = re.flags() & regex_constants::icase;
estimate_max_state_count(static_cast<category*>(0));
if(!(m_match_flags & (match_perl|match_posix)))
{
if(re.flags() & regbase::perlex)
if(re.flags() & regex_constants::perlex)
m_match_flags |= match_perl;
else
m_match_flags |= match_posix;
@ -104,7 +104,7 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match()
position = base;
search_base = base;
state_count = 0;
m_presult->set_size(re.mark_count(), base, last);
m_presult->set_size((m_match_flags & match_nosubs) ? 1 : re.mark_count(), base, last);
m_presult->set_base(base);
if(m_match_flags & match_posix)
m_result = *m_presult;
@ -156,7 +156,7 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::find()
position = base;
search_base = base;
pstate = access::first(re);
m_presult->set_size(re.mark_count(), base, last);
m_presult->set_size((m_match_flags & match_nosubs) ? 1 : re.mark_count(), base, last);
m_presult->set_base(base);
m_match_flags |= match_init;
}
@ -174,7 +174,7 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::find()
++position;
}
// reset $` start:
m_presult->set_size(re.mark_count(), search_base, last);
m_presult->set_size((m_match_flags & match_nosubs) ? 1 : re.mark_count(), search_base, last);
if(base != search_base)
m_match_flags |= match_prev_avail;
}
@ -242,7 +242,8 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_endmark()
int index = static_cast<const re_brace*>(pstate)->index;
if(index > 0)
{
m_presult->set_second(position, index);
if((m_match_flags & match_nosubs) == 0)
m_presult->set_second(position, index);
}
else if(index < 0)
{
@ -706,7 +707,7 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::find_restart_lit
int len = info->len;
const char_type* x = info->pstr;
int j = 0;
bool icase = re.flags() & regbase::icase;
bool icase = re.flags() & regex_constants::icase;
while (position != last)
{
while((j > -1) && (x[j] != traits_inst.translate(*position, icase)))

View File

@ -311,8 +311,11 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_startmark(
default:
{
assert(index > 0);
push_matched_paren(index, (*m_presult)[index]);
m_presult->set_first(position, index);
if((m_match_flags & match_nosubs) == 0)
{
push_matched_paren(index, (*m_presult)[index]);
m_presult->set_first(position, index);
}
pstate = pstate->next.p;
break;
}

View File

@ -105,12 +105,19 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_startmark(
default:
{
assert(index > 0);
backup_subex<BidiIterator> sub(*m_presult, index);
m_presult->set_first(position, index);
pstate = pstate->next.p;
r = match_all_states();
if(r == false)
sub.restore(*m_presult);
if((m_match_flags & match_nosubs) == 0)
{
backup_subex<BidiIterator> sub(*m_presult, index);
m_presult->set_first(position, index);
pstate = pstate->next.p;
r = match_all_states();
if(r == false)
sub.restore(*m_presult);
}
else
{
pstate = pstate->next.p;
}
break;
}
}

View File

@ -52,18 +52,24 @@ public:
failbit = use_except << 1, // error flag
literal = failbit << 1, // all characters are literals
icase = literal << 1, // characters are matched regardless of case
nocollate = icase << 1, // don't use locale specific collation
perlex = nocollate << 1, // perl extensions
nocollate = 0, // don't use locale specific collation (deprecated)
collate = icase << 1, // use locale specific collation
perlex = collate << 1, // perl extensions
nosubs = perlex << 1, // don't mark sub-expressions
optimize = 0, // not really supported
basic = char_classes | intervals | limited_ops | bk_braces | bk_parens | bk_refs,
extended = char_classes | intervals | bk_refs,
basic = char_classes | intervals | limited_ops | bk_braces | bk_parens | bk_refs | collate,
extended = char_classes | intervals | bk_refs | collate,
normal = perlex | escape_in_lists | char_classes | intervals | bk_refs | nocollate,
emacs = bk_braces | bk_parens | bk_refs | bk_vbar,
awk = extended | escape_in_lists,
grep = basic | newline_alt,
egrep = extended | newline_alt,
sed = basic,
perl = normal
perl = normal,
ECMAScript = normal,
JavaScript = normal,
JScript = normal
};
typedef unsigned int flag_type;
@ -91,6 +97,51 @@ protected:
flag_type _flags;
};
//
// provide std lib proposal compatible constants:
//
namespace regex_constants{
enum flag_type_
{
escape_in_lists = ::boost::regbase::escape_in_lists,
char_classes = ::boost::regbase::char_classes,
intervals = ::boost::regbase::intervals,
limited_ops = ::boost::regbase::limited_ops,
newline_alt = ::boost::regbase::newline_alt,
bk_plus_qm = ::boost::regbase::bk_plus_qm,
bk_braces = ::boost::regbase::bk_braces,
bk_parens = ::boost::regbase::bk_parens,
bk_refs = ::boost::regbase::bk_refs,
bk_vbar = ::boost::regbase::bk_vbar,
use_except = ::boost::regbase::use_except,
failbit = ::boost::regbase::failbit,
literal = ::boost::regbase::literal,
icase = ::boost::regbase::icase,
nocollate = ::boost::regbase::nocollate,
collate = ::boost::regbase::collate,
perlex = ::boost::regbase::perlex,
nosubs = ::boost::regbase::nosubs,
optimize = ::boost::regbase::optimize,
basic = ::boost::regbase::basic,
extended = ::boost::regbase::extended,
normal = ::boost::regbase::normal,
emacs = ::boost::regbase::emacs,
awk = ::boost::regbase::awk,
grep = ::boost::regbase::grep,
egrep = ::boost::regbase::egrep,
sed = basic,
perl = normal,
ECMAScript = normal,
JavaScript = normal,
JScript = normal
};
typedef ::boost::regbase::flag_type syntax_option_type;
} // namespace regex_constants
} // namespace boost
#ifdef __BORLANDC__

View File

@ -145,6 +145,9 @@ typedef match_results<std::wstring::const_iterator> wsmatch;
#ifndef BOOST_REGEX_V4_REGEX_GREP_HPP
#include <boost/regex/v4/regex_grep.hpp>
#endif
#ifndef BOOST_REGEX_V4_REGEX_REPLACE_HPP
#include <boost/regex/v4/regex_replace.hpp>
#endif
#ifndef BOOST_REGEX_V4_REGEX_MERGE_HPP
#include <boost/regex/v4/regex_merge.hpp>
#endif

View File

@ -51,7 +51,7 @@ bool BOOST_REGEX_CALL re_maybe_set_member(charT c,
const reg_expression<charT, traits_type, Allocator>& e)
{
const charT* p = reinterpret_cast<const charT*>(set_+1);
bool icase = e.flags() & regbase::icase;
bool icase = e.flags() & regex_constants::icase;
charT col = e.get_traits().translate(c, icase);
for(unsigned int i = 0; i < set_->csingles; ++i)
{
@ -91,21 +91,21 @@ template <class charT, class traits, class Allocator>
reg_expression<charT, traits, Allocator>::reg_expression(const charT* p, flag_type f, const Allocator& a)
: data(a), pkmp(0), error_code_(REG_EMPTY), _expression(0)
{
set_expression(p, f | regbase::use_except);
set_expression(p, f | regex_constants::use_except);
}
template <class charT, class traits, class Allocator>
reg_expression<charT, traits, Allocator>::reg_expression(const charT* p1, const charT* p2, flag_type f, const Allocator& a)
: data(a), pkmp(0), error_code_(REG_EMPTY), _expression(0)
{
set_expression(p1, p2, f | regbase::use_except);
set_expression(p1, p2, f | regex_constants::use_except);
}
template <class charT, class traits, class Allocator>
reg_expression<charT, traits, Allocator>::reg_expression(const charT* p, size_type len, flag_type f, const Allocator& a)
: data(a), pkmp(0), error_code_(REG_EMPTY), _expression(0)
{
set_expression(p, p + len, f | regbase::use_except);
set_expression(p, p + len, f | regex_constants::use_except);
}
template <class charT, class traits, class Allocator>
@ -118,11 +118,11 @@ reg_expression<charT, traits, Allocator>::reg_expression(const reg_expression<ch
if(e.error_code() == 0)
{
const charT* pe = e.expression();
set_expression(pe, pe + e._expression_len, e.flags() | regbase::use_except);
set_expression(pe, pe + e._expression_len, e.flags() | regex_constants::use_except);
}
else
{
_flags = e.flags() & ~(regbase::use_except);
_flags = e.flags() & ~(regex_constants::use_except);
fail(e.error_code());
}
}
@ -144,7 +144,7 @@ reg_expression<charT, traits, Allocator>& BOOST_REGEX_CALL reg_expression<charT,
_flags = use_except;
fail(e.error_code());
if(error_code() == 0)
set_expression(e._expression, e._expression + e._expression_len, e.flags() | regbase::use_except);
set_expression(e._expression, e._expression + e._expression_len, e.flags() | regex_constants::use_except);
return *this;
}
@ -498,12 +498,12 @@ bool BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::probe_start(
case re_detail::syntax_element_literal:
// only the first character of the literal can match:
// note these have already been translated:
if(*reinterpret_cast<charT*>(static_cast<re_detail::re_literal*>(node)+1) == traits_inst.translate(cc, (_flags & regbase::icase)))
if(*reinterpret_cast<charT*>(static_cast<re_detail::re_literal*>(node)+1) == traits_inst.translate(cc, (_flags & regex_constants::icase)))
return true;
return false;
case re_detail::syntax_element_end_line:
// next character (if there is one!) must be a newline:
if(traits_inst.is_separator(traits_inst.translate(cc, (_flags & regbase::icase))))
if(traits_inst.is_separator(traits_inst.translate(cc, (_flags & regex_constants::icase))))
return true;
return false;
case re_detail::syntax_element_wild:
@ -512,10 +512,10 @@ bool BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::probe_start(
return true;
case re_detail::syntax_element_within_word:
case re_detail::syntax_element_word_start:
return traits_inst.is_class(traits_inst.translate(cc, (_flags & regbase::icase)), traits_type::char_class_word);
return traits_inst.is_class(traits_inst.translate(cc, (_flags & regex_constants::icase)), traits_type::char_class_word);
case re_detail::syntax_element_word_end:
// what follows must not be a word character,
return traits_inst.is_class(traits_inst.translate(cc, (_flags & regbase::icase)), traits_type::char_class_word) ? false : true;
return traits_inst.is_class(traits_inst.translate(cc, (_flags & regex_constants::icase)), traits_type::char_class_word) ? false : true;
case re_detail::syntax_element_buffer_end:
// we can be null, nothing must follow,
// NB we assume that this is followed by
@ -527,7 +527,7 @@ bool BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::probe_start(
// NB we assume that this is followed by
// re_detail::syntax_element_match, if its not then we can
// never match anything anyway!!
return traits_inst.is_separator(traits_inst.translate(cc, (_flags & regbase::icase)));
return traits_inst.is_separator(traits_inst.translate(cc, (_flags & regex_constants::icase)));
case re_detail::syntax_element_backref:
// there's no easy way to determine this
// which is not to say it can't be done!
@ -540,7 +540,7 @@ bool BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::probe_start(
return re_detail::re_maybe_set_member(cc, static_cast<const re_detail::re_set_long*>(node), *this) || (re_detail::re_is_set_member(static_cast<const charT*>(&cc), static_cast<const charT*>(&cc+1), static_cast<re_detail::re_set_long*>(node), *this) != &cc);
case re_detail::syntax_element_set:
// set all the elements that are set in corresponding set:
c = (traits_size_type)(traits_uchar_type)traits_inst.translate(cc, (_flags & regbase::icase));
c = (traits_size_type)(traits_uchar_type)traits_inst.translate(cc, (_flags & regex_constants::icase));
return static_cast<re_detail::re_set*>(node)->_map[c] != 0;
case re_detail::syntax_element_jump:
if(static_cast<re_detail::re_jump*>(node)->alt.p < node)
@ -583,7 +583,7 @@ bool BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::probe_start(
else
return probe_start(node->next.p, cc, static_cast<re_detail::re_jump*>(node)->alt.p);
case re_detail::syntax_element_combining:
return !traits_inst.is_combining(traits_inst.translate(cc, (_flags & regbase::icase)));
return !traits_inst.is_combining(traits_inst.translate(cc, (_flags & regex_constants::icase)));
}
return false;
}
@ -777,7 +777,7 @@ re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression<charT, traits, Alloca
return 0;
}
boost::uint_fast32_t id = traits_inst.lookup_classname(base+2, first-2);
if(_flags & regbase::icase)
if(_flags & regex_constants::icase)
{
if((id == traits_type::char_class_upper) || (id == traits_type::char_class_lower))
{
@ -819,7 +819,7 @@ re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression<charT, traits, Alloca
unsigned i = 0;
while(i < len)
{
s[i] = traits_inst.translate(s[i], (_flags & regbase::icase));
s[i] = traits_inst.translate(s[i], (_flags & regex_constants::icase));
++i;
}
traits_string_type s2;
@ -901,7 +901,7 @@ re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression<charT, traits, Alloca
l = last_dash;
continue;
case traits_type::syntax_slash:
if(_flags & regbase::escape_in_lists)
if(_flags & regex_constants::escape_in_lists)
{
++first;
if(first == last)
@ -994,7 +994,7 @@ re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression<charT, traits, Alloca
std::size_t len = s.size();
while(i < len)
{
s[i] = traits_inst.translate(s[i], (_flags & regbase::icase));
s[i] = traits_inst.translate(s[i], (_flags & regex_constants::icase));
++i;
}
started = true;
@ -1025,7 +1025,7 @@ re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression<charT, traits, Alloca
result = compile_set_aux(singles, ranges, classes, equivalents, isnot, width_type());
#ifdef __BORLANDC__
// delayed throw:
if((result == 0) && (_flags & regbase::use_except))
if((result == 0) && (_flags & regex_constants::use_except))
fail(error_code());
#endif
return result;
@ -1040,7 +1040,7 @@ re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression<charT, traits, Alloca
unsigned int cranges = 0;
boost::uint_fast32_t cclasses = 0;
unsigned int cequivalents = 0;
bool nocollate_state = flags() & regbase::nocollate;
bool nocollate_state = !(flags() & regex_constants::collate);
bool singleton = true;
while(singles.empty() == false)
@ -1074,7 +1074,7 @@ re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression<charT, traits, Alloca
// delay throw to later:
#ifdef __BORLANDC__
boost::uint_fast32_t f = _flags;
_flags &= ~regbase::use_except;
_flags &= ~regex_constants::use_except;
#endif
fail(REG_ERANGE);
#ifdef __BORLANDC__
@ -1129,12 +1129,12 @@ re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression<charT, traits, Alloca
{
traits_string_type c1, c2, c3, c4;
if(flags() & regbase::nocollate)
if((flags() & regex_constants::collate) == 0)
c1 = ranges.peek();
else
traits_inst.transform(c1, ranges.peek());
ranges.pop();
if(flags() & regbase::nocollate)
if((flags() & regex_constants::collate) == 0)
c2 = ranges.peek();
else
traits_inst.transform(c2, ranges.peek());
@ -1148,7 +1148,7 @@ re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression<charT, traits, Alloca
// delay throw to later:
#ifdef __BORLANDC__
boost::uint_fast32_t f = _flags;
_flags &= ~regbase::use_except;
_flags &= ~regex_constants::use_except;
#endif
fail(REG_ERANGE);
#ifdef __BORLANDC__
@ -1159,7 +1159,7 @@ re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression<charT, traits, Alloca
for(unsigned int i = 0; i < 256; ++i)
{
c4 = (charT)i;
if(flags() & regbase::nocollate)
if((flags() & regex_constants::collate) == 0)
c3 = c4;
else
traits_inst.transform(c3, c4);
@ -1191,7 +1191,7 @@ re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression<charT, traits, Alloca
for(unsigned int i = 0; i < 256; ++i)
{
if(traits_inst.is_class(charT(i), flags))
dat->_map[(traits_uchar_type)traits_inst.translate((charT)i, (_flags & regbase::icase))] = re_detail::mask_all;
dat->_map[(traits_uchar_type)traits_inst.translate((charT)i, (_flags & regex_constants::icase))] = re_detail::mask_all;
}
}
@ -1317,7 +1317,7 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::set_expr
#endif
#ifdef __OpenBSD__
// strxfrm not working on OpenBSD??
f |= regbase::nocollate;
f &= ~regex_constants::collate;
#endif
if(p == expression())
@ -1357,11 +1357,11 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::set_expr
++marks;
dat = 0;
if(_flags & regbase::literal)
if(_flags & regex_constants::literal)
{
while(ptr != end)
{
dat = add_literal(dat, traits_inst.translate(*ptr, (_flags & regbase::icase)));
dat = add_literal(dat, traits_inst.translate(*ptr, (_flags & regex_constants::icase)));
++ptr;
}
}
@ -1384,8 +1384,16 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::set_expr
open_bracked_jump:
// extend:
dat = add_simple(dat, re_detail::syntax_element_startmark, sizeof(re_detail::re_brace));
markid.push(marks);
static_cast<re_detail::re_brace*>(dat)->index = marks++;
if(_flags & nosubs)
{
markid.push(0);
static_cast<re_detail::re_brace*>(dat)->index = 0;
}
else
{
markid.push(marks);
static_cast<re_detail::re_brace*>(dat)->index = marks++;
}
mark.push(data.index(dat));
++ptr;
//
@ -1811,7 +1819,7 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::set_expr
dat = compile_set(ptr, end);
if(dat == 0)
{
if((_flags & regbase::failbit) == 0)
if((_flags & regex_constants::failbit) == 0)
fail(REG_EBRACK);
return error_code();
}
@ -1963,7 +1971,7 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::set_expr
fixup_apply(static_cast<re_detail::re_syntax_base*>(data.data()), marks);
// check for error during fixup:
if(_flags & regbase::failbit)
if(_flags & regex_constants::failbit)
return error_code();
//
@ -1985,7 +1993,7 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::set_expr
{
charT* p1 = reinterpret_cast<charT*>(reinterpret_cast<char*>(sbase) + sizeof(re_detail::re_literal));
charT* p2 = p1 + static_cast<re_detail::re_literal*>(sbase)->length;
pkmp = re_detail::kmp_compile(p1, p2, charT(), re_detail::kmp_translator<traits>(_flags&regbase::icase, &traits_inst), data.allocator());
pkmp = re_detail::kmp_compile(p1, p2, charT(), re_detail::kmp_translator<traits>(_flags&regex_constants::icase, &traits_inst), data.allocator());
}
}
return error_code();
@ -2022,7 +2030,7 @@ re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression<charT, traits, Alloca
{
// add another charT to the list:
std::ptrdiff_t pos = reinterpret_cast<unsigned char*>(dat) - reinterpret_cast<unsigned char*>(data.data());
*reinterpret_cast<charT*>(data.extend(sizeof(charT))) = traits_inst.translate(c, (_flags & regbase::icase));
*reinterpret_cast<charT*>(data.extend(sizeof(charT))) = traits_inst.translate(c, (_flags & regex_constants::icase));
dat = reinterpret_cast<re_detail::re_syntax_base*>(reinterpret_cast<unsigned char*>(data.data()) + pos);
++(static_cast<re_detail::re_literal*>(dat)->length);
}
@ -2031,7 +2039,7 @@ re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression<charT, traits, Alloca
// extend:
dat = add_simple(dat, re_detail::syntax_element_literal, sizeof(re_detail::re_literal) + sizeof(charT));
static_cast<re_detail::re_literal*>(dat)->length = 1;
*reinterpret_cast<charT*>(reinterpret_cast<re_detail::re_literal*>(dat)+1) = traits_inst.translate(c, (_flags & regbase::icase));
*reinterpret_cast<charT*>(reinterpret_cast<re_detail::re_literal*>(dat)+1) = traits_inst.translate(c, (_flags & regex_constants::icase));
}
return dat;
}
@ -2082,7 +2090,7 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::fixup_le
leading_lit = false;
const charT* p1 = _leading_string;
const charT* p2 = _leading_string + _leading_string_len;
pkmp = re_detail::kmp_compile(p1, p2, charT(), re_detail::kmp_translator<traits>(_flags&regbase::icase, &traits_inst), data.allocator());
pkmp = re_detail::kmp_compile(p1, p2, charT(), re_detail::kmp_translator<traits>(_flags&regex_constants::icase, &traits_inst), data.allocator());
}
leading_lit = false;
break;
@ -2140,16 +2148,16 @@ void BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::fail(unsigned in
error_code_ = err;
if(err)
{
_flags |= regbase::failbit;
_flags |= regex_constants::failbit;
#ifndef BOOST_NO_EXCEPTIONS
if(_flags & regbase::use_except)
if(_flags & regex_constants::use_except)
{
re_detail::raise_error(traits_inst, err);
}
#endif
}
else
_flags &= ~regbase::failbit;
_flags &= ~regex_constants::failbit;
}

View File

@ -337,7 +337,7 @@ expand_sub:
continue;
}
case traits_type::syntax_open_bracket:
if(flags & (format_sed|format_perl))
if(0 == (flags & format_all))
{
*out = *fmt;
++out;
@ -351,7 +351,7 @@ expand_sub:
continue;
}
case traits_type::syntax_close_bracket:
if(flags & (format_sed|format_perl))
if(0 == (flags & format_all))
{
*out = *fmt;
++out;
@ -375,7 +375,7 @@ expand_sub:
continue;
case traits_type::syntax_question:
{
if(flags & (format_sed|format_perl))
if(0 == (flags & format_all))
{
*out = *fmt;
++out;

View File

@ -42,7 +42,7 @@ inline unsigned int regex_grep(Predicate foo,
const reg_expression<charT, traits, Allocator>& e,
match_flag_type flags = match_default)
{
if(e.flags() & regbase::failbit)
if(e.flags() & regex_constants::failbit)
return false;
typedef detail::rebind_allocator<sub_match<BidiIterator>, Allocator> binder;
typedef typename binder::type match_allocator_type;

View File

@ -33,17 +33,14 @@ namespace boost{
#endif
template <class OutputIterator, class Iterator, class traits, class Allocator, class charT>
OutputIterator regex_merge(OutputIterator out,
inline OutputIterator regex_merge(OutputIterator out,
Iterator first,
Iterator last,
const reg_expression<charT, traits, Allocator>& e,
const charT* fmt,
match_flag_type flags = match_default)
{
Iterator l = first;
re_detail::merge_out_predicate<OutputIterator, Iterator, charT, Allocator, traits> oi(out, l, fmt, flags, e.get_traits());
regex_grep(oi, first, last, e, flags);
return (flags & format_no_copy) ? out : re_detail::re_copy_out(out, l, last);
return regex_replace(out, first, last, e, fmt, flags);
}
template <class OutputIterator, class Iterator, class traits, class Allocator, class charT>
@ -58,27 +55,21 @@ inline OutputIterator regex_merge(OutputIterator out,
}
template <class traits, class Allocator, class charT>
std::basic_string<charT> regex_merge(const std::basic_string<charT>& s,
inline std::basic_string<charT> regex_merge(const std::basic_string<charT>& s,
const reg_expression<charT, traits, Allocator>& e,
const charT* fmt,
match_flag_type flags = match_default)
{
std::basic_string<charT> result;
re_detail::string_out_iterator<std::basic_string<charT> > i(result);
regex_merge(i, s.begin(), s.end(), e, fmt, flags);
return result;
return regex_replace(s, e, fmt, flags);
}
template <class traits, class Allocator, class charT>
std::basic_string<charT> regex_merge(const std::basic_string<charT>& s,
inline std::basic_string<charT> regex_merge(const std::basic_string<charT>& s,
const reg_expression<charT, traits, Allocator>& e,
const std::basic_string<charT>& fmt,
match_flag_type flags = match_default)
{
std::basic_string<charT> result;
re_detail::string_out_iterator<std::basic_string<charT> > i(result);
regex_merge(i, s.begin(), s.end(), e, fmt.c_str(), flags);
return result;
return regex_replace(s, e, fmt, flags);
}
#ifdef __BORLANDC__

View File

@ -0,0 +1,91 @@
/*
*
* Copyright (c) 1998-2002
* Dr John Maddock
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Dr John Maddock makes no representations
* about the suitability of this software for any purpose.
* It is provided "as is" without express or implied warranty.
*
*/
/*
* LOCATION: see http://www.boost.org for most recent version.
* FILE regex_format.hpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Provides formatting output routines for search and replace
* operations. Note this is an internal header file included
* by regex.hpp, do not include on its own.
*/
#ifndef BOOST_REGEX_V4_REGEX_REPLACE_HPP
#define BOOST_REGEX_V4_REGEX_REPLACE_HPP
namespace boost{
#ifdef __BORLANDC__
#pragma option push -a8 -b -Vx -Ve -pc -w-8037
#endif
template <class OutputIterator, class Iterator, class traits, class Allocator, class charT>
OutputIterator regex_replace(OutputIterator out,
Iterator first,
Iterator last,
const reg_expression<charT, traits, Allocator>& e,
const charT* fmt,
match_flag_type flags = match_default)
{
Iterator l = first;
re_detail::merge_out_predicate<OutputIterator, Iterator, charT, Allocator, traits> oi(out, l, fmt, flags, e.get_traits());
regex_grep(oi, first, last, e, flags);
return (flags & format_no_copy) ? out : re_detail::re_copy_out(out, l, last);
}
template <class OutputIterator, class Iterator, class traits, class Allocator, class charT>
inline OutputIterator regex_replace(OutputIterator out,
Iterator first,
Iterator last,
const reg_expression<charT, traits, Allocator>& e,
const std::basic_string<charT>& fmt,
match_flag_type flags = match_default)
{
return regex_replace(out, first, last, e, fmt.c_str(), flags);
}
template <class traits, class Allocator, class charT>
std::basic_string<charT> regex_replace(const std::basic_string<charT>& s,
const reg_expression<charT, traits, Allocator>& e,
const charT* fmt,
match_flag_type flags = match_default)
{
std::basic_string<charT> result;
re_detail::string_out_iterator<std::basic_string<charT> > i(result);
regex_replace(i, s.begin(), s.end(), e, fmt, flags);
return result;
}
template <class traits, class Allocator, class charT>
std::basic_string<charT> regex_replace(const std::basic_string<charT>& s,
const reg_expression<charT, traits, Allocator>& e,
const std::basic_string<charT>& fmt,
match_flag_type flags = match_default)
{
std::basic_string<charT> result;
re_detail::string_out_iterator<std::basic_string<charT> > i(result);
regex_replace(i, s.begin(), s.end(), e, fmt.c_str(), flags);
return result;
}
#ifdef __BORLANDC__
#pragma option pop
#endif
} // namespace boost
#endif // BOOST_REGEX_V4_REGEX_REPLACE_HPP

View File

@ -36,7 +36,7 @@ bool regex_search(BidiIterator first, BidiIterator last,
const reg_expression<charT, traits, Allocator2>& e,
match_flag_type flags = match_default)
{
if(e.flags() & regbase::failbit)
if(e.flags() & regex_constants::failbit)
return false;
re_detail::perl_matcher<BidiIterator, Allocator, traits, Allocator2> matcher(first, last, m, e, flags);
@ -103,6 +103,89 @@ inline bool regex_search(const std::basic_string<wchar_t>& s,
#endif
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template <class BidiIterator, class charT, class traits, class Allocator2>
bool regex_search(BidiIterator first, BidiIterator last,
const reg_expression<charT, traits, Allocator2>& e,
match_flag_type flags = match_default)
{
if(e.flags() & regex_constants::failbit)
return false;
match_results<BidiIterator> m;
typedef typename match_results<BidiIterator>::allocator_type match_alloc_type;
re_detail::perl_matcher<BidiIterator, match_alloc_type, traits, Allocator2> matcher(first, last, m, e, flags);
return matcher.find();
}
template <class charT, class traits, class Allocator2>
inline bool regex_search(const charT* str,
const reg_expression<charT, traits, Allocator2>& e,
match_flag_type flags = match_default)
{
return regex_search(str, str + traits::length(str), e, flags);
}
template <class ST, class SA, class charT, class traits, class Allocator2>
inline bool regex_search(const std::basic_string<charT, ST, SA>& s,
const reg_expression<charT, traits, Allocator2>& e,
match_flag_type flags = match_default)
{
return regex_search(s.begin(), s.end(), e, flags);
}
#else // non-template function overloads
inline bool regex_search(const char* first, const char* last,
const regex& e,
match_flag_type flags = match_default)
{
cmatch m;
return regex_search(first, last, m, e, flags);
}
#ifndef BOOST_NO_WREGEX
inline bool regex_search(const wchar_t* first, const wchar_t* last,
const wregex& e,
match_flag_type flags = match_default)
{
wcmatch m;
return regex_search(first, last, m, e, flags);
}
#endif
inline bool regex_search(const char* str,
const regex& e,
match_flag_type flags = match_default)
{
cmatch m;
return regex_search(str, str + regex::traits_type::length(str), m, e, flags);
}
#ifndef BOOST_NO_WREGEX
inline bool regex_search(const wchar_t* str,
const wregex& e,
match_flag_type flags = match_default)
{
wcmatch m;
return regex_search(str, str + wregex::traits_type::length(str), m, e, flags);
}
#endif
inline bool regex_search(const std::string& s,
const regex& e,
match_flag_type flags = match_default)
{
smatch m;
return regex_search(s.begin(), s.end(), m, e, flags);
}
#if !defined(BOOST_NO_WREGEX)
inline bool regex_search(const std::basic_string<wchar_t>& s,
const wregex& e,
match_flag_type flags = match_default)
{
wsmatch m;
return regex_search(s.begin(), s.end(), m, e, flags);
}
#endif
#endif
#ifdef __BORLANDC__
#pragma option pop
#endif

View File

@ -205,6 +205,57 @@ bool operator >= (typename re_detail::regex_iterator_traits<RandomAccessIterator
const sub_match<RandomAccessIterator>& m)
{ return m.str().compare(s) <= 0; }
// comparison to const charT& part 1:
template <class RandomAccessIterator>
bool operator == (const sub_match<RandomAccessIterator>& m,
typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s)
{ return m.str().compare(0, m.length(), &s, 1) == 0; }
template <class RandomAccessIterator>
bool operator != (const sub_match<RandomAccessIterator>& m,
typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s)
{ return m.str().compare(0, m.length(), &s, 1) != 0; }
template <class RandomAccessIterator>
bool operator > (const sub_match<RandomAccessIterator>& m,
typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s)
{ return m.str().compare(0, m.length(), &s, 1) > 0; }
template <class RandomAccessIterator>
bool operator < (const sub_match<RandomAccessIterator>& m,
typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s)
{ return m.str().compare(0, m.length(), &s, 1) < 0; }
template <class RandomAccessIterator>
bool operator >= (const sub_match<RandomAccessIterator>& m,
typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s)
{ return m.str().compare(0, m.length(), &s, 1) >= 0; }
template <class RandomAccessIterator>
bool operator <= (const sub_match<RandomAccessIterator>& m,
typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s)
{ return m.str().compare(0, m.length(), &s, 1) <= 0; }
// comparison to const charT* part 2:
template <class RandomAccessIterator>
bool operator == (typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s,
const sub_match<RandomAccessIterator>& m)
{ return m.str().compare(0, m.length(), &s, 1) == 0; }
template <class RandomAccessIterator>
bool operator != (typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s,
const sub_match<RandomAccessIterator>& m)
{ return m.str().compare(0, m.length(), &s, 1) != 0; }
template <class RandomAccessIterator>
bool operator < (typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s,
const sub_match<RandomAccessIterator>& m)
{ return m.str().compare(0, m.length(), &s, 1) > 0; }
template <class RandomAccessIterator>
bool operator > (typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s,
const sub_match<RandomAccessIterator>& m)
{ return m.str().compare(0, m.length(), &s, 1) < 0; }
template <class RandomAccessIterator>
bool operator <= (typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s,
const sub_match<RandomAccessIterator>& m)
{ return m.str().compare(0, m.length(), &s, 1) >= 0; }
template <class RandomAccessIterator>
bool operator >= (typename re_detail::regex_iterator_traits<RandomAccessIterator>::value_type const& s,
const sub_match<RandomAccessIterator>& m)
{ return m.str().compare(0, m.length(), &s, 1) <= 0; }
#ifndef BOOST_NO_STD_LOCALE
template <class charT, class traits, class RandomAccessIterator>
std::basic_ostream<charT, traits>&

150
index.htm
View File

@ -1,150 +0,0 @@
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta name="keywords"
content="regex++, regular expressions, regular expression library, C++">
<meta name="Template"
content="C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\html.dot">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
<title>regex++, Index</title>
</head>
<body bgcolor="#FFFFFF" link="#0000FF" vlink="#800080">
<p>&nbsp; </p>
<table border="0" cellpadding="7" cellspacing="0" width="100%">
<tr>
<td valign="top"><h3><img src="../../c++boost.gif"
alt="C++ Boost" width="277" height="86"></h3>
</td>
<td valign="top"><h3 align="center">Regex++, Index.</h3>
<p align="left"><i>(Version 3.31, 16th Dec 2001)</i>&nbsp;
</p>
<p align="left"><i>Copyright (c) 1998-2001 </i></p>
<p align="left"><i>Dr John Maddock</i></p>
<p align="left"><i>Permission to use, copy, modify,
distribute and sell this software and its documentation
for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and
that both that copyright notice and this permission
notice appear in supporting documentation. Dr John
Maddock makes no representations about the suitability of
this software for any purpose. It is provided &quot;as is&quot;
without express or implied warranty.</i></p>
</td>
</tr>
</table>
<hr>
<h3 align="center">Contents</h3>
<ul>
<li><a href="introduction.htm#intro">Introduction</a></li>
<li><a href="introduction.htm#Installation">Installation and
Configuration</a> </li>
<li><a href="template_class_ref.htm#regbase">Template Class
and Algorithm Reference</a> <ul>
<li>Class <a href="template_class_ref.htm#regbase">regbase</a></li>
<li>Class <a
href="template_class_ref.htm#bad_expression">bad_expression</a>
</li>
<li>Class <a
href="template_class_ref.htm#reg_expression">reg_expression</a>
</li>
<li>Class <a
href="template_class_ref.htm#regex_char_traits">char_regex_traits</a></li>
<li>Class <a href="template_class_ref.htm#reg_match">match_results</a>
</li>
<li>Algorithm <a
href="template_class_ref.htm#query_match">regex_match</a>
</li>
<li>Algorithm <a
href="template_class_ref.htm#reg_search">regex_search</a>
</li>
<li>Algorithm <a
href="template_class_ref.htm#reg_grep">regex_grep</a></li>
<li>Algorithm <a
href="template_class_ref.htm#reg_format">regex_format</a>
</li>
<li>Algorithm <a
href="template_class_ref.htm#reg_merge">regex_merge</a></li>
<li>Algorithm <a
href="template_class_ref.htm#regex_split">regex_split</a>
</li>
<li><a href="template_class_ref.htm#partial_matches">Partial
regular expression matches</a></li>
</ul>
</li>
<li>Class <a href="hl_ref.htm#RegEx">RegEx</a> reference</li>
<li><a href="posix_ref.htm#posix">POSIX Compatibility
Functions</a></li>
<li><a href="syntax.htm#syntax">Regular Expression Syntax</a></li>
<li><a href="format_string.htm#format_string">Format String
Syntax</a></li>
<li><a href="appendix.htm#implementation">Appendices</a> <ul>
<li><a href="appendix.htm#implementation">Implementation
notes</a></li>
<li><a href="appendix.htm#threads">Thread safety</a></li>
<li><a href="appendix.htm#localisation">Localization</a></li>
<li><a href="appendix.htm#demos">Example Applications</a>
<ul>
<li><a
href="example/snippets/regex_match_example.cpp">regex_match_example.cpp</a>:
ftp based regex_match example.</li>
<li><a
href="example/snippets/regex_search_example.cpp">regex_search_example.cpp</a>:
regex_search example: searches a cpp file
for class definitions.</li>
<li><a
href="example/snippets/regex_grep_example_1.cpp">regex_grep_example_1.cpp</a>:
regex_grep example 1: searches a cpp file
for class definitions.</li>
<li><a
href="example/snippets/regex_merge_example.cpp">regex_merge_example.cpp</a>:
regex_merge example: converts a C++ file
to syntax highlighted HTML.</li>
<li><a
href="example/snippets/regex_grep_example_2.cpp">regex_grep_example_2.cpp</a>:
regex_grep example 2: searches a cpp file
for class definitions, using a global
callback function. </li>
<li><a
href="example/snippets/regex_grep_example_3.cpp">regex_grep_example_3.cpp</a>:
regex_grep example 2: searches a cpp file
for class definitions, using a bound
member function callback.</li>
<li><a
href="example/snippets/regex_grep_example_4.cpp">regex_grep_example_4.cpp</a>:
regex_grep example 2: searches a cpp file
for class definitions, using a C++
Builder closure as a callback.</li>
<li><a
href="example/snippets/regex_split_example_1.cpp">regex_split_example_1.cpp</a>:
regex_split example: split a string into
tokens.</li>
<li><a
href="example/snippets/regex_split_example_2.cpp">regex_split_example_2.cpp</a>:
regex_split example: spit out linked
URL's.</li>
</ul>
</li>
<li><a href="appendix.htm#headers">Header Files.</a></li>
<li><a href="appendix.htm#redist">Redistributables</a></li>
<li><a href="appendix.htm#upgrade">Note for upgraders</a></li>
</ul>
</li>
<li><a href="appendix.htm#furtherInfo">Further Information (Contacts
and Acknowledgements)</a></li>
<li><a href="faq.htm">FAQ</a></li>
</ul>
<hr>
<p><i>Copyright </i><a href="mailto:John_Maddock@compuserve.com"><i>Dr
John Maddock</i></a><i> 1998-2001 all rights reserved.</i> </p>
</body>
</html>

View File

@ -1,476 +0,0 @@
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta name="keywords"
content="regex++, regular expressions, regular expression library, C++">
<meta name="Template"
content="C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\html.dot">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
<title>regex++, Introduction</title>
</head>
<body bgcolor="#FFFFFF" link="#0000FF" vlink="#800080">
<p>&nbsp; </p>
<table border="0" cellpadding="7" cellspacing="0" width="100%">
<tr>
<td valign="top"><h3><img src="../../c++boost.gif"
alt="C++ Boost" width="276" height="86"></h3>
</td>
<td valign="top"><h3 align="center">Regex++, Introduction.</h3>
<p align="left"><i>Copyright (c) 1998-2001 </i></p>
<p align="left"><i>Dr John Maddock</i></p>
<p align="left"><i>Permission to use, copy, modify,
distribute and sell this software and its documentation
for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and
that both that copyright notice and this permission
notice appear in supporting documentation. Dr John
Maddock makes no representations about the suitability of
this software for any purpose. It is provided &quot;as is&quot;
without express or implied warranty.</i></p>
</td>
</tr>
</table>
<hr>
<h3><a name="intro"></a><i>Introduction</i></h3>
<p>Regular expressions are a form of pattern-matching that are
often used in text processing; many users will be familiar with
the Unix utilities <i>grep</i>, <i>sed</i> and <i>awk</i>, and
the programming language <i>perl</i>, each of which make
extensive use of regular expressions. Traditionally C++ users
have been limited to the POSIX C API's for manipulating regular
expressions, and while regex++ does provide these API's, they do
not represent the best way to use the library. For example regex++
can cope with wide character strings, or search and replace
operations (in a manner analogous to either sed or perl),
something that traditional C libraries can not do.</p>
<p>The class <a href="template_class_ref.htm#reg_expression">boost::reg_expression</a>
is the key class in this library; it represents a &quot;machine
readable&quot; regular expression, and is very closely modelled
on std::basic_string, think of it as a string plus the actual
state-machine required by the regular expression algorithms. Like
std::basic_string there are two typedefs that are almost always
the means by which this class is referenced:</p>
<pre><b>namespace </b>boost{
<b>template</b> &lt;<b>class</b> charT,
<b> class</b> traits = regex_traits&lt;charT&gt;,
<b>class</b> Allocator = std::allocator&lt;charT&gt; &gt;
<b>class</b> reg_expression;
<b>typedef</b> reg_expression&lt;<b>char</b>&gt; regex;
<b>typedef</b> reg_expression&lt;<b>wchar_t&gt;</b> wregex;
}</pre>
<p>To see how this library can be used, imagine that we are
writing a credit card processing application. Credit card numbers
generally come as a string of 16-digits, separated into groups of
4-digits, and separated by either a space or a hyphen. Before
storing a credit card number in a database (not necessarily
something your customers will appreciate!), we may want to verify
that the number is in the correct format. To match any digit we
could use the regular expression [0-9], however ranges of
characters like this are actually locale dependent. Instead we
should use the POSIX standard form [[:digit:]], or the regex++
and perl shorthand for this \d (note that many older libraries
tended to be hard-coded to the C-locale, consequently this was
not an issue for them). That leaves us with the following regular
expression to validate credit card number formats:</p>
<p>(\d{4}[- ]){3}\d{4}</p>
<p>Here the parenthesis act to group (and mark for future
reference) sub-expressions, and the {4} means &quot;repeat
exactly 4 times&quot;. This is an example of the extended regular
expression syntax used by perl, awk and egrep. Regex++ also
supports the older &quot;basic&quot; syntax used by sed and grep,
but this is generally less useful, unless you already have some
basic regular expressions that you need to reuse.</p>
<p>Now lets take that expression and place it in some C++ code to
validate the format of a credit card number:</p>
<pre><b>bool</b> validate_card_format(<b>const</b> std::string s)
{
<b>static</b> <b>const</b> <a
href="template_class_ref.htm#reg_expression">boost::regex</a> e(&quot;(\\d{4}[- ]){3}\\d{4}&quot;);
<b>return</b> <a href="template_class_ref.htm#query_match">regex_match</a>(s, e);
}</pre>
<p>Note how we had to add some extra escapes to the expression:
remember that the escape is seen once by the C++ compiler, before
it gets to be seen by the regular expression engine, consequently
escapes in regular expressions have to be doubled up when
embedding them in C/C++ code. Also note that all the examples
assume that your compiler supports Koenig lookup, if yours
doesn't (for example VC6), then you will have to add some boost::
prefixes to some of the function calls in the examples.</p>
<p>Those of you who are familiar with credit card processing,
will have realised that while the format used above is suitable
for human readable card numbers, it does not represent the format
required by online credit card systems; these require the number
as a string of 16 (or possibly 15) digits, without any
intervening spaces. What we need is a means to convert easily
between the two formats, and this is where search and replace
comes in. Those who are familiar with the utilities <i>sed</i>
and <i>perl</i> will already be ahead here; we need two strings -
one a regular expression - the other a &quot;<a
href="format_string.htm">format string</a>&quot; that provides a
description of the text to replace the match with. In regex++
this search and replace operation is performed with the algorithm
regex_merge, for our credit card example we can write two
algorithms like this to provide the format conversions:</p>
<pre>
<i>// match any format with the regular expression:
</i><b>const</b> boost::regex e(&quot;\\A(\\d{3,4})[- ]?(\\d{4})[- ]?(\\d{4})[- ]?(\\d{4})\\z&quot;);
<b>const</b> std::string machine_format(&quot;\\1\\2\\3\\4&quot;);
<b>const</b> std::string human_format(&quot;\\1-\\2-\\3-\\4&quot;);
std::string machine_readable_card_number(<b>const</b> std::string s)
{
<b>return</b> <a href="template_class_ref.htm#reg_merge">regex_merge</a>(s, e, machine_format, boost::match_default | boost::format_sed);
}
std::string human_readable_card_number(<b>const</b> std::string s)
{
<b>return</b> <a href="template_class_ref.htm#reg_merge">regex_merge</a>(s, e, human_format, boost::match_default | boost::format_sed);
}</pre>
<p>Here we've used marked sub-expressions in the regular
expression to split out the four parts of the card number as
separate fields, the format string then uses the sed-like syntax
to replace the matched text with the reformatted version.</p>
<p>In the examples above, we haven't directly manipulated the
results of a regular expression match, however in general the
result of a match contains a number of sub-expression matches in
addition to the overall match. When the library needs to report a
regular expression match it does so using an instance of the
class <a href="template_class_ref.htm#reg_match">match_results</a>,
as before there are typedefs of this class for the most common
cases: </p>
<pre><b>namespace </b>boost{
<b>typedef</b> match_results&lt;<b>const</b> <b>char</b>*&gt; cmatch;
<b>typedef</b> match_results&lt;<b>const</b> <b>wchar_t</b>*&gt; wcmatch;
<strong>typedef</strong> match_results&lt;std::string::const_iterator&gt; smatch;
<strong>typedef</strong> match_results&lt;std::wstring::const_iterator&gt; wsmatch;
}</pre>
<p>The algorithms <a href="template_class_ref.htm#reg_search">regex_search</a>
and <a href="template_class_ref.htm#reg_grep">regex_grep</a> (i.e.
finding all matches in a string) make use of match_results to
report what matched.</p>
<p>Note that these algorithms are not restricted to searching
regular C-strings, any bidirectional iterator type can be
searched, allowing for the possibility of seamlessly searching
almost any kind of data. </p>
<p>For search and replace operations in addition to the algorithm
<a href="template_class_ref.htm#reg_merge">regex_merge</a> that
we have already seen, the algorithm <a
href="template_class_ref.htm#reg_format">regex_format</a> takes
the result of a match and a format string, and produces a new
string by merging the two.</p>
<p>For those that dislike templates, there is a high level
wrapper class RegEx that is an encapsulation of the lower level
template code - it provides a simplified interface for those that
don't need the full power of the library, and supports only
narrow characters, and the &quot;extended&quot; regular
expression syntax. </p>
<p>The <a href="posix_ref.htm#posix">POSIX API</a> functions:
regcomp, regexec, regfree and regerror, are available in both
narrow character and Unicode versions, and are provided for those
who need compatibility with these API's. </p>
<p>Finally, note that the library now has run-time <a
href="appendix.htm#localisation">localization</a> support, and
recognizes the full POSIX regular expression syntax - including
advanced features like multi-character collating elements and
equivalence classes - as well as providing compatibility with
other regular expression libraries including GNU and BSD4 regex
packages, and to a more limited extent perl 5. </p>
<h3><a name="Installation"></a><i>Installation and Configuration
Options</i> </h3>
<p><em>[ </em><strong><i>Important</i></strong><em>: If you are
upgrading from the 2.x version of this library then you will find
a number of changes to the documented header names and library
interfaces, existing code should still compile unchanged however
- see </em><a href="appendix.htm#upgrade"><font color="#0000FF"><em>Note
for Upgraders</em></font></a><em>. ]</em></p>
<p>When you extract the library from its zip file, you must
preserve its internal directory structure (for example by using
the -d option when extracting). If you didn't do that when
extracting, then you'd better stop reading this, delete the files
you just extracted, and try again! </p>
<p>This library should not need configuring before use; most
popular compilers/standard libraries/platforms are already
supported &quot;as is&quot;. If you do experience configuration
problems, or just want to test the configuration with your
compiler, then the process is the same as for all of boost; see
the <a href="../config/config.htm">configuration library
documentation</a>.</p>
<p>The library will encase all code inside namespace boost. </p>
<p>Unlike some other template libraries, this library consists of
a mixture of template code (in the headers) and static code and
data (in cpp files). Consequently it is necessary to build the
library's support code into a library or archive file before you
can use it, instructions for specific platforms are as follows: </p>
<p><b>Borland C++ Builder:</b> </p>
<ul>
<li>Open up a console window and change to the
&lt;boost&gt;\libs\regex\build directory. </li>
<li>Select the appropriate makefile (bcb4.mak for C++ Builder
4, bcb5.mak for C++ Builder 5, and bcb6.mak for C++
Builder 6). </li>
<li>Invoke the makefile (pass the full path to your version
of make if you have more than one version installed, the
makefile relies on the path to make to obtain your C++
Builder installation directory and tools) for example: </li>
</ul>
<pre>make -fbcb5.mak</pre>
<p>The build process will build a variety of .lib and .dll files
(the exact number depends upon the version of Borland's tools you
are using) the .lib and dll files will be in a sub-directory
called bcb4 or bcb5 depending upon the makefile used. To install
the libraries into your development system use:</p>
<p>make -fbcb5.mak install</p>
<p>library files will be copied to &lt;BCROOT&gt;/lib and the
dll's to &lt;BCROOT&gt;/bin, where &lt;BCROOT&gt; corresponds to
the install path of your Borland C++ tools. </p>
<p>You may also remove temporary files created during the build
process (excluding lib and dll files) by using:</p>
<p>make -fbcb5.mak clean</p>
<p>Finally when you use regex++ it is only necessary for you to
add the &lt;boost&gt; root director to your list of include
directories for that project. It is not necessary for you to
manually add a .lib file to the project; the headers will
automatically select the correct .lib file for your build mode
and tell the linker to include it. There is one caveat however:
the library can not tell the difference between VCL and non-VCL
enabled builds when building a GUI application from the command
line, if you build from the command line with the 5.5 command
line tools then you must define the pre-processor symbol _NO_VCL
in order to ensure that the correct link libraries are selected:
the C++ Builder IDE normally sets this automatically. Hint, users
of the 5.5 command line tools may want to add a -D_NO_VCL to bcc32.cfg
in order to set this option permanently. </p>
<p>If you would prefer to do a static link to the regex libraries
even when using the dll runtime then define
BOOST_REGEX_STATIC_LINK, and if you want to suppress automatic
linking altogether (and supply your own custom build of the lib)
then define BOOST_REGEX_NO_LIB.</p>
<p>If you are building with C++ Builder 6, you will find that
&lt;boost/regex.hpp&gt; can not be used in a pre-compiled header
(the actual problem is in &lt;locale&gt; which gets included by
&lt;boost/regex.hpp&gt;), if this causes problems for you, then
try defining BOOST_NO_STD_LOCALE when building, this will disable
some features throughout boost, but may save you a lot in compile
times!</p>
<p><b>Microsoft Visual C++ 6</b><strong> and 7</strong></p>
<p>You need version 6 of MSVC to build this library. If you are
using VC5 then you may want to look at one of the previous
releases of this <a
href="http://ourworld.compuserve.com/homepages/john_maddock/regexpp.htm">library</a>
</p>
<p>Open up a command prompt, which has the necessary MSVC
environment variables defined (for example by using the batch
file Vcvars32.bat installed by the Visual Studio installation),
and change to the &lt;boost&gt;\libs\regex\build directory. </p>
<p>Select the correct makefile - vc6.mak for &quot;vanilla&quot;
Visual C++ 6 or vc6-stlport.mak if you are using STLPort.</p>
<p>Invoke the makefile like this:</p>
<p>nmake -fvc6.mak</p>
<p>You will now have a collection of lib and dll files in a
&quot;vc6&quot; subdirectory, to install these into your
development system use:</p>
<p>nmake -fvc6.mak install</p>
<p>The lib files will be copied to your &lt;VC6&gt;\lib directory
and the dll files to &lt;VC6&gt;\bin, where &lt;VC6&gt; is the
root of your Visual C++ 6 installation.</p>
<p>You can delete all the temporary files created during the
build (excluding lib and dll files) using:</p>
<p>nmake -fvc6.mak clean </p>
<p>Finally when you use regex++ it is only necessary for you to
add the &lt;boost&gt; root directory to your list of include
directories for that project. It is not necessary for you to
manually add a .lib file to the project; the headers will
automatically select the correct .lib file for your build mode
and tell the linker to include it. </p>
<p>Note that if you want to statically link to the regex library
when using the dynamic C++ runtime, define
BOOST_REGEX_STATIC_LINK when building your project (this only has
an effect for release builds). If you want to add the source
directly to your project then define BOOST_REGEX_NO_LIB to
disable automatic library selection.</p>
<p><strong><i>Important</i></strong><em>: there have been some
reports of compiler-optimisation bugs affecting this library, (particularly
with VC6 versions prior to service patch 5) the workaround is to
build the library using /Oityb1 rather than /O2. That is to use
all optimisation settings except /Oa. This problem is reported to
affect some standard library code as well (in fact I'm not sure
if the problem is with the regex code or the underlying standard
library), so it's probably worthwhile applying this workaround in
normal practice in any case.</em></p>
<p>Note: if you have replaced the C++ standard library that comes
with VC6, then when you build the library you must ensure that
the environment variables &quot;INCLUDE&quot; and &quot;LIB&quot;
have been updated to reflect the include and library paths for
the new library - see vcvars32.bat (part of your Visual Studio
installation) for more details. Alternatively if STLPort is in c:/stlport
then you could use:</p>
<p>nmake INCLUDES=&quot;-Ic:/stlport/stlport&quot; XLFLAGS=&quot;/LIBPATH:c:/stlport/lib&quot;
-fvc6-stlport.mak</p>
<p>If you are building with the full STLPort v4.x, then use the
vc6-stlport.mak file provided and set the environment variable
STLPORT_PATH to point to the location of your STLport
installation (Note that the full STLPort libraries appear not to
support single-thread static builds). <br>
&nbsp; <br>
&nbsp; </p>
<p><b>GCC(2.95)</b> </p>
<p>There is a conservative makefile for the g++ compiler. From
the command prompt change to the &lt;boost&gt;/libs/regex/build
directory and type: </p>
<p>make -fgcc.mak </p>
<p>At the end of the build process you should have a gcc sub-directory
containing release and debug versions of the library (libboost_regex.a
and libboost_regex_debug.a). When you build projects that use
regex++, you will need to add the boost install directory to your
list of include paths and add &lt;boost&gt;/libs/regex/build/gcc/libboost_regex.a
to your list of library files. </p>
<p>There is also a makefile to build the library as a shared
library:</p>
<p>make -fgcc-shared.mak</p>
<p>which will build libboost_regex.so and libboost_regex_debug.so.</p>
<p>Both of the these makefiles support the following environment
variables:</p>
<p>CXXFLAGS: extra compiler options - note that this applies to
both the debug and release builds.</p>
<p>INCLUDES: additional include directories.</p>
<p>LDFLAGS: additional linker options.</p>
<p>LIBS: additional library files.</p>
<p>For the more adventurous there is a configure script in
&lt;boost&gt;/libs/config; see the <a href="../config/config.htm">config
library documentation</a>.</p>
<p><b>Sun Workshop 6.1</b></p>
<p>There is a makefile for the sun (6.1) compiler (C++ version 3.12).
From the command prompt change to the &lt;boost&gt;/libs/regex/build
directory and type: </p>
<p>dmake -f sunpro.mak </p>
<p>At the end of the build process you should have a sunpro sub-directory
containing single and multithread versions of the library (libboost_regex.a,
libboost_regex.so, libboost_regex_mt.a and libboost_regex_mt.so).
When you build projects that use regex++, you will need to add
the boost install directory to your list of include paths and add
&lt;boost&gt;/libs/regex/build/sunpro/ to your library search
path. </p>
<p>Both of the these makefiles support the following environment
variables:</p>
<p>CXXFLAGS: extra compiler options - note that this applies to
both the single and multithreaded builds.</p>
<p>INCLUDES: additional include directories.</p>
<p>LDFLAGS: additional linker options.</p>
<p>LIBS: additional library files.</p>
<p>LIBSUFFIX: a suffix to mangle the library name with (defaults
to nothing).</p>
<p>This makefile does not set any architecture specific options
like -xarch=v9, you can set these by defining the appropriate
macros, for example:</p>
<p>dmake CXXFLAGS=&quot;-xarch=v9&quot; LDFLAGS=&quot;-xarch=v9&quot;
LIBSUFFIX=&quot;_v9&quot; -f sunpro.mak</p>
<p>will build v9 variants of the regex library named
libboost_regex_v9.a etc.</p>
<p><b>Other compilers:</b> </p>
<p>There is a generic makefile (<a href="build/generic.mak">generic.mak</a>)
provided in &lt;boost-root&gt;/libs/regex/build - see that
makefile for details of environment variables that need to be set
before use. Alternatively you can using the <a
href="../../tools/build/index.html">Jam based build system</a>.
If you need to configure the library for your platform, then
refer to the <a href="../config/config.htm">config library
documentation</a>.</p>
<hr>
<p><i>Copyright </i><a href="mailto:John_Maddock@compuserve.com"><i>Dr
John Maddock</i></a><i> 1998-2001 all rights reserved.</i> </p>
</body>
</html>

43
performance/Jamfile Normal file
View File

@ -0,0 +1,43 @@
subproject libs/regex/performance ;
SOURCES = command_line main time_boost time_greta time_localised_boost time_pcre time_posix time_safe_greta ;
if $(HS_REGEX_PATH)
{
HS_SOURCES = $(HS_REGEX_PATH)/regcomp.c $(HS_REGEX_PATH)/regerror.c $(HS_REGEX_PATH)/regexec.c $(HS_REGEX_PATH)/regfree.c ;
POSIX_OPTS = <define>BOOST_HAS_POSIX=1 <include>$(HS_REGEX_PATH) ;
}
else if $(USE_POSIX)
{
POSIX_OPTS = <define>BOOST_HAS_POSIX=1 ;
}
if $(PCRE_PATH)
{
PCRE_SOURCES = $(PCRE_PATH)/chartables.c $(PCRE_PATH)/get.c $(PCRE_PATH)/pcre.c $(PCRE_PATH)/study.c ;
PCRE_OPTS = <define>BOOST_HAS_PCRE=1 <include>$(PCRE_PATH) ;
}
else if $(USE_PCRE)
{
PCRE_OPTS = <define>BOOST_HAS_PCRE=1 <find-library>pcre ;
}
exe regex_comparison :
$(SOURCES).cpp
$(HS_SOURCES)
$(PCRE_SOURCES)
<lib>../build/boost_regex
<lib>../../test/build/boost_prg_exec_monitor
:
<include>$(BOOST_ROOT)
<define>BOOST_REGEX_NO_LIB=1
<define>BOOST_REGEX_STATIC_LINK=1
$(POSIX_OPTS)
$(PCRE_OPTS)
;

View File

@ -6,6 +6,8 @@
#include <sstream>
#include <stdexcept>
#include <iterator>
#include <boost/regex.hpp>
#include <boost/version.hpp>
#include "regex_comparison.hpp"
//
@ -190,6 +192,13 @@ void print_result(std::ostream& os, double time, double best)
os << "</td>";
}
std::string html_quote(const std::string& in)
{
static const boost::regex e("(<)|(>)|(&)|(\")");
static const std::string format("(?1&lt;)(?2&gt;)(?3&amp;)(?4&quot;)");
return regex_replace(in, e, format);
}
void output_html_results(bool show_description, const std::string& tagname)
{
std::stringstream os;
@ -230,9 +239,9 @@ void output_html_results(bool show_description, const std::string& tagname)
last = result_list.end();
while(first != last)
{
os << "<tr><td><code>" << first->expression << "</code></td>";
os << "<tr><td><code>" << html_quote(first->expression) << "</code></td>";
if(show_description)
os << "<td>" << first->description << "</td>";
os << "<td>" << html_quote(first->description) << "</td>";
#if defined(BOOST_HAS_GRETA)
if(time_greta == true)
print_result(os, first->greta_time, first->factor);
@ -264,7 +273,7 @@ void output_html_results(bool show_description, const std::string& tagname)
std::string result = os.str();
unsigned int pos = html_contents.find(tagname);
std::string::size_type pos = html_contents.find(tagname);
if(pos != std::string::npos)
{
html_contents.replace(pos, tagname.size(), result);
@ -275,6 +284,42 @@ void output_final_html()
{
if(html_out_file.size())
{
//
// start with search and replace ops:
//
std::string::size_type pos;
pos = html_contents.find("%compiler%");
if(pos != std::string::npos)
{
html_contents.replace(pos, 10, BOOST_COMPILER);
}
pos = html_contents.find("%library%");
if(pos != std::string::npos)
{
html_contents.replace(pos, 9, BOOST_STDLIB);
}
pos = html_contents.find("%os%");
if(pos != std::string::npos)
{
html_contents.replace(pos, 4, BOOST_PLATFORM);
}
pos = html_contents.find("%boost%");
if(pos != std::string::npos)
{
html_contents.replace(pos, 7, BOOST_STRINGIZE(BOOST_VERSION));
}
pos = html_contents.find("%pcre%");
if(pos != std::string::npos)
{
#ifdef PCRE_MINOR
html_contents.replace(pos, 6, BOOST_STRINGIZE(PCRE_MAJOR.PCRE_MINOR));
#else
html_contents.replace(pos, 6, "N/A");
#endif
}
//
// now right the output to file:
//
std::ofstream os(html_out_file.c_str());
os << html_contents;
}

View File

@ -1,59 +1,64 @@
<html>
<head>
<title>Regular Expression Performance Comparison</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<meta name="Template" content="C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\html.dot">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
</head>
<body bgcolor="#ffffff" link="#0000ff" vlink="#800080">
<h2>Regular Expression Performance Comparison</h2>
<p>The Boost and GRETA regular expression libraries have slightly different
interfaces, and it has been suggested that GRETA's interface allows for a more
efficient implementation. The following tables provide comparisons between:</p>
<p><a href="http://research.microsoft.com/projects/greta">GRETA</a>.</p>
<p><a href="http://www.boost.org/">The Boost regex library</a>.</p>
<p><a href="http://arglist.com/regex/">Henry Spencer's regular expression library</a>
- this is provided for comparison as a typical non-backtracking implementation.</p>
<p>
Times were obtained on a 2.8GHz Pentium&nbsp;4 PC running Windows XP, and the
code was compiled with Visual C++ 7.1 with all optimisations turned on. As ever
care should be taken in interpreting the results, only sensible regular
expressions (rather than pathological cases) are given, most are taken from the
Boost regex examples, or from the <a href="http://www.regxlib.com/">Library of
Regular Expressions</a>. In addition, some variation in the relative
performance of these libraries can be expected on other machines - as memory
access and processor caching effects can be quite large for most finite state
machine algorithms.</p>
<h3>Comparison 1: Long Search</h3>
<p>For each of the following regular expressions the time taken to find all
occurrences of the expression within a long English language text was measured
(<a href="ftp://ibiblio.org/pub/docs/books/gutenberg/etext02/mtent12.zip">mtent12.txt</a>
from <a href="http://promo.net/pg/">Project Gutenberg</a>, 19Mb).&nbsp;</p>
<P>%long_twain_search%</P>
<h3>Comparison 2: Medium Sized Search</h3>
<p>For each of the following regular expressions the time taken to find all
occurrences of the expression within a medium sized English language text was
measured (the first 50K from mtent12.txt).&nbsp;</p>
<P>%short_twain_search%</P>
<H3>Comparison 3:&nbsp;C++ Code&nbsp;Search</H3>
<P>For each of the following regular expressions the time taken to find all
occurrences of the expression within the C++ source file <A href="../../../boost/crc.hpp">
boost/crc.hpp</A>&nbsp;was measured.&nbsp;</P>
<P>%code_search%</P>
<H3>
<H3>Comparison 4: HTML Document Search</H3>
</H3>
<P>For each of the following regular expressions the time taken to find all
occurrences of the expression within the html file <A href="../../libraries.htm">libs/libraries.htm</A>
was measured.&nbsp;</P>
<P>%html_search%</P>
<H3>Comparison 3: Simple Matches</H3>
<p>
For each of the following regular expressions the time taken to match against
the text indicated was measured.&nbsp;</p>
<P>%short_matches%</P>
<hr>
<p>Copyright John Maddock April 2003, all rights reserved.</p>
</body>
<head>
<title>Regular Expression Performance Comparison</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<meta name="Template" content="C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\html.dot">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
</head>
<body bgcolor="#ffffff" link="#0000ff" vlink="#800080">
<h2>Regular Expression Performance Comparison</h2>
<p>The Boost and GRETA regular expression libraries have slightly different
interfaces, and it has been suggested that GRETA's interface allows for a more
efficient implementation. The following tables provide comparisons between:</p>
<p><a href="http://research.microsoft.com/projects/greta">GRETA</a>.</p>
<p><a href="http://www.boost.org/">The Boost regex library</a>.</p>
<p><a href="http://arglist.com/regex/">Henry Spencer's regular expression library</a>
- this is provided for comparison as a typical non-backtracking implementation.</p>
<H3>Details</H3>
<P>Machine: Intel Pentium 4 2.8GHz PC.</P>
<P>Compiler: %compiler%.</P>
<P>C++ Standard Library: %library%.</P>
<P>OS: %os%.</P>
<P>Boost version: %boost%.</P>
<P>PCRE version: %pcre%.</P>
<P>
As ever care should be taken in interpreting the results, only sensible regular
expressions (rather than pathological cases) are given, most are taken from the
Boost regex examples, or from the <a href="http://www.regxlib.com/">Library of
Regular Expressions</a>. In addition, some variation in the relative
performance of these libraries can be expected on other machines - as memory
access and processor caching effects can be quite large for most finite state
machine algorithms.</P>
<h3>Comparison 1: Long Search</h3>
<p>For each of the following regular expressions the time taken to find all
occurrences of the expression within a long English language text was measured
(<a href="ftp://ibiblio.org/pub/docs/books/gutenberg/etext02/mtent12.zip">mtent12.txt</a>
from <a href="http://promo.net/pg/">Project Gutenberg</a>, 19Mb).&nbsp;</p>
<P>%long_twain_search%</P>
<h3>Comparison 2: Medium Sized Search</h3>
<p>For each of the following regular expressions the time taken to find all
occurrences of the expression within a medium sized English language text was
measured (the first 50K from mtent12.txt).&nbsp;</p>
<P>%short_twain_search%</P>
<H3>Comparison 3:&nbsp;C++ Code&nbsp;Search</H3>
<P>For each of the following regular expressions the time taken to find all
occurrences of the expression within the C++ source file <A href="../../../boost/crc.hpp">
boost/crc.hpp</A>&nbsp;was measured.&nbsp;</P>
<P>%code_search%</P>
<H3>
<H3>Comparison 4: HTML Document Search</H3>
</H3>
<P>For each of the following regular expressions the time taken to find all
occurrences of the expression within the html file <A href="../../libraries.htm">libs/libraries.htm</A>
was measured.&nbsp;</P>
<P>%html_search%</P>
<H3>Comparison 3: Simple Matches</H3>
<p>
For each of the following regular expressions the time taken to match against
the text indicated was measured.&nbsp;</p>
<P>%short_matches%</P>
<hr>
<p>Copyright John Maddock April 2003, all rights reserved.</p>
</body>
</html>

View File

@ -232,7 +232,7 @@ int cpp_main(int argc, char * argv[])
if(test_long_twain)
{
load_file(file_contents, "mtent12.txt");
load_file(file_contents, "mtent13.txt");
test_find_all("Twain", file_contents);
test_find_all("Huck[[:alpha:]]+", file_contents);

View File

@ -21,7 +21,7 @@ namespace b{
double time_match(const std::string& re, const std::string& text, bool icase)
{
boost::regex e(re, (icase ? boost::regbase::perl | boost::regbase::icase : boost::regbase::perl));
boost::regex e(re, (icase ? boost::regex::perl | boost::regex::icase : boost::regex::perl));
boost::smatch what;
boost::timer tim;
int iter = 1;
@ -59,7 +59,7 @@ bool dummy_grep_proc(const boost::smatch&)
double time_find_all(const std::string& re, const std::string& text, bool icase)
{
boost::regex e(re, (icase ? boost::regbase::perl | boost::regbase::icase : boost::regbase::perl));
boost::regex e(re, (icase ? boost::regex::perl | boost::regex::icase : boost::regex::perl));
boost::smatch what;
boost::timer tim;
int iter = 1;

View File

@ -21,7 +21,7 @@ namespace bl{
double time_match(const std::string& re, const std::string& text, bool icase)
{
boost::reg_expression<char, boost::cpp_regex_traits<char> > e(re, (icase ? boost::regbase::perl | boost::regbase::icase : boost::regbase::perl));
boost::reg_expression<char, boost::cpp_regex_traits<char> > e(re, (icase ? boost::regex::perl | boost::regex::icase : boost::regex::perl));
boost::smatch what;
boost::timer tim;
int iter = 1;
@ -59,7 +59,7 @@ bool dummy_grep_proc(const boost::smatch&)
double time_find_all(const std::string& re, const std::string& text, bool icase)
{
boost::reg_expression<char, boost::cpp_regex_traits<char> > e(re, (icase ? boost::regbase::perl | boost::regbase::icase : boost::regbase::perl));
boost::reg_expression<char, boost::cpp_regex_traits<char> > e(re, (icase ? boost::regex::perl | boost::regex::icase : boost::regex::perl));
boost::smatch what;
boost::timer tim;
int iter = 1;

View File

@ -1,314 +0,0 @@
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta name="Template"
content="C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\html.dot">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
<title>Regex++, POSIX API Reference</title>
</head>
<body bgcolor="#FFFFFF" link="#0000FF" vlink="#800080">
<p>&nbsp; </p>
<table border="0" cellpadding="7" cellspacing="0" width="100%">
<tr>
<td valign="top"><h3><img src="../../c++boost.gif"
alt="C++ Boost" width="276" height="86"></h3>
</td>
<td valign="top"><h3 align="center">Regex++, POSIX API
Reference. </h3>
<p align="left"><i>Copyright (c) 1998-2001 </i></p>
<p align="left"><i>Dr John Maddock</i></p>
<p align="left"><i>Permission to use, copy, modify,
distribute and sell this software and its documentation
for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and
that both that copyright notice and this permission
notice appear in supporting documentation. Dr John
Maddock makes no representations about the suitability of
this software for any purpose. It is provided &quot;as is&quot;
without express or implied warranty.</i></p>
</td>
</tr>
</table>
<hr>
<h3><a name="posix"></a><i>POSIX compatibility library</i></h3>
<pre>#include &lt;boost/cregex.hpp&gt;
<i>or</i>:
#include &lt;boost/regex.h&gt;</pre>
<p>The following functions are available for users who need a
POSIX compatible C library, they are available in both Unicode
and narrow character versions, the standard POSIX API names are
macros that expand to one version or the other depending upon
whether UNICODE is defined or not. </p>
<p><b>Important</b>: Note that all the symbols defined here are
enclosed inside namespace <i>boost</i> when used in C++ programs,
unless you use #include &lt;boost/regex.h&gt; instead - in which
case the symbols are still defined in namespace boost, but are
made available in the global namespace as well.</p>
<p>The functions are defined as: </p>
<pre>extern &quot;C&quot; {
<b>int</b> regcompA(regex_tA*, <b>const</b> <b>char</b>*, <b>int</b>);
<b>unsigned</b> <b>int</b> regerrorA(<b>int</b>, <b>const</b> regex_tA*, <b>char</b>*, <b>unsigned</b> <b>int</b>);
<b>int</b> regexecA(<b>const</b> regex_tA*, <b>const</b> <b>char</b>*, <b>unsigned</b> <b>int</b>, regmatch_t*, <b>int</b>);
<b>void</b> regfreeA(regex_tA*);
<b>int</b> regcompW(regex_tW*, <b>const</b> <b>wchar_t</b>*, <b>int</b>);
<b>unsigned</b> <b>int</b> regerrorW(<b>int</b>, <b>const</b> regex_tW*, <b>wchar_t</b>*, <b>unsigned</b> <b>int</b>);
<b>int</b> regexecW(<b>const</b> regex_tW*, <b>const</b> <b>wchar_t</b>*, <b>unsigned</b> <b>int</b>, regmatch_t*, <b>int</b>);
<b>void</b> regfreeW(regex_tW*);
#ifdef UNICODE
#define regcomp regcompW
#define regerror regerrorW
#define regexec regexecW
#define regfree regfreeW
#define regex_t regex_tW
#else
#define regcomp regcompA
#define regerror regerrorA
#define regexec regexecA
#define regfree regfreeA
#define regex_t regex_tA
#endif
}</pre>
<p>All the functions operate on structure <b>regex_t</b>, which
exposes two public members: </p>
<p><b>unsigned int re_nsub</b> this is filled in by <b>regcomp</b>
and indicates the number of sub-expressions contained in the
regular expression. </p>
<p><b>const TCHAR* re_endp</b> points to the end of the
expression to compile when the flag REG_PEND is set. </p>
<p><i>Footnote: regex_t is actually a #define - it is either
regex_tA or regex_tW depending upon whether UNICODE is defined or
not, TCHAR is either char or wchar_t again depending upon the
macro UNICODE.</i> </p>
<p><b>regcomp</b> takes a pointer to a <b>regex_t</b>, a pointer
to the expression to compile and a flags parameter which can be a
combination of: <br>
&nbsp; </p>
<table border="0" cellpadding="7" cellspacing="0" width="100%">
<tr>
<td width="5%">&nbsp;</td>
<td valign="top" width="45%">REG_EXTENDED</td>
<td valign="top" width="45%">Compiles modern regular
expressions. Equivalent to regbase::char_classes |
regbase::intervals | regbase::bk_refs.</td>
<td width="5%">&nbsp;</td>
</tr>
<tr>
<td width="5%">&nbsp;</td>
<td valign="top" width="45%">REG_BASIC</td>
<td valign="top" width="45%">Compiles basic (obsolete)
regular expression syntax. Equivalent to regbase::char_classes
| regbase::intervals | regbase::limited_ops | regbase::bk_braces
| regbase::bk_parens | regbase::bk_refs.</td>
<td width="5%">&nbsp;</td>
</tr>
<tr>
<td width="5%">&nbsp;</td>
<td valign="top" width="45%">REG_NOSPEC</td>
<td valign="top" width="45%">All characters are ordinary,
the expression is a literal string.</td>
<td width="5%">&nbsp;</td>
</tr>
<tr>
<td width="5%">&nbsp;</td>
<td valign="top" width="45%">REG_ICASE</td>
<td valign="top" width="45%">Compiles for matching that
ignores character case.</td>
<td width="5%">&nbsp;</td>
</tr>
<tr>
<td width="5%">&nbsp;</td>
<td valign="top" width="45%">REG_NOSUB</td>
<td valign="top" width="45%">Has no effect in this
library.</td>
<td width="5%">&nbsp;</td>
</tr>
<tr>
<td width="5%">&nbsp;</td>
<td valign="top" width="45%">REG_NEWLINE</td>
<td valign="top" width="45%">When this flag is set a dot
does not match the newline character.</td>
<td width="5%">&nbsp;</td>
</tr>
<tr>
<td width="5%">&nbsp;</td>
<td valign="top" width="45%">REG_PEND</td>
<td valign="top" width="45%">When this flag is set the
re_endp parameter of the regex_t structure must point to
the end of the regular expression to compile.</td>
<td width="5%">&nbsp;</td>
</tr>
<tr>
<td width="5%">&nbsp;</td>
<td valign="top" width="45%">REG_NOCOLLATE</td>
<td valign="top" width="45%">When this flag is set then
locale dependent collation for character ranges is turned
off.</td>
<td width="5%">&nbsp;</td>
</tr>
<tr>
<td width="5%">&nbsp;</td>
<td valign="top" width="45%">REG_ESCAPE_IN_LISTS<br>
, , , </td>
<td valign="top" width="45%">When this flag is set, then
escape sequences are permitted in bracket expressions (character
sets).</td>
<td width="5%">&nbsp;</td>
</tr>
<tr>
<td width="5%">&nbsp;</td>
<td valign="top" width="45%">REG_NEWLINE_ALT&nbsp;</td>
<td valign="top" width="45%">When this flag is set then
the newline character is equivalent to the alternation
operator |.</td>
<td width="5%">&nbsp;</td>
</tr>
<tr>
<td width="5%">&nbsp;</td>
<td valign="top" width="45%">REG_PERL&nbsp;</td>
<td valign="top" width="45%">&nbsp;A shortcut for perl-like
behavior: REG_EXTENDED | REG_NOCOLLATE |
REG_ESCAPE_IN_LISTS</td>
<td width="5%">&nbsp;</td>
</tr>
<tr>
<td width="5%">&nbsp;</td>
<td valign="top" width="45%">REG_AWK</td>
<td valign="top" width="45%">A shortcut for awk-like
behavior: REG_EXTENDED | REG_ESCAPE_IN_LISTS</td>
<td width="5%">&nbsp;</td>
</tr>
<tr>
<td width="5%">&nbsp;</td>
<td valign="top" width="45%">REG_GREP</td>
<td valign="top" width="45%">A shortcut for grep like
behavior: REG_BASIC | REG_NEWLINE_ALT</td>
<td width="5%">&nbsp;</td>
</tr>
<tr>
<td width="5%">&nbsp;</td>
<td valign="top" width="45%">REG_EGREP</td>
<td valign="top" width="45%">&nbsp;A shortcut for egrep
like behavior: REG_EXTENDED | REG_NEWLINE_ALT</td>
<td width="5%">&nbsp;</td>
</tr>
</table>
<p><br>
&nbsp; </p>
<p><b>regerror</b> takes the following parameters, it maps an
error code to a human readable string: <br>
&nbsp; </p>
<table border="0" cellpadding="7" cellspacing="0" width="100%">
<tr>
<td width="5%">&nbsp;</td>
<td valign="top" width="50%">int code</td>
<td valign="top" width="50%">The error code.</td>
<td width="5%">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td valign="top" width="50%">const regex_t* e</td>
<td valign="top" width="50%">The regular expression (can
be null).</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td valign="top" width="50%">char* buf</td>
<td valign="top" width="50%">The buffer to fill in with
the error message.</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td valign="top" width="50%">unsigned int buf_size</td>
<td valign="top" width="50%">The length of buf.</td>
<td>&nbsp;</td>
</tr>
</table>
<p>If the error code is OR'ed with REG_ITOA then the message that
results is the printable name of the code rather than a message,
for example &quot;REG_BADPAT&quot;. If the code is REG_ATIO then <b>e</b>
must not be null and <b>e-&gt;re_pend</b> must point to the
printable name of an error code, the return value is then the
value of the error code. For any other value of <b>code</b>, the
return value is the number of characters in the error message, if
the return value is greater than or equal to <b>buf_size</b> then
<b>regerror</b> will have to be called again with a larger buffer.</p>
<p><b>regexec</b> finds the first occurrence of expression <b>e</b>
within string <b>buf</b>. If <b>len</b> is non-zero then *<b>m</b>
is filled in with what matched the regular expression, <b>m[0]</b>
contains what matched the whole string, <b>m[1] </b>the first sub-expression
etc, see <b>regmatch_t</b> in the header file declaration for
more details. The <b>eflags</b> parameter can be a combination of:
<br>
&nbsp; </p>
<table border="0" cellpadding="7" cellspacing="0" width="100%">
<tr>
<td width="5%">&nbsp;</td>
<td valign="top" width="50%">REG_NOTBOL</td>
<td valign="top" width="50%">Parameter <b>buf </b>does
not represent the start of a line.</td>
<td width="5%">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td valign="top" width="50%">REG_NOTEOL</td>
<td valign="top" width="50%">Parameter <b>buf</b> does
not terminate at the end of a line.</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td valign="top" width="50%">REG_STARTEND</td>
<td valign="top" width="50%">The string searched starts
at buf + pmatch[0].rm_so and ends at buf + pmatch[0].rm_eo.</td>
<td>&nbsp;</td>
</tr>
</table>
<p><br>
&nbsp; </p>
<p>Finally <b>regfree</b> frees all the memory that was allocated
by regcomp. </p>
<p><i>Footnote: this is an abridged reference to the POSIX API
functions, it is provided for compatibility with other libraries,
rather than an API to be used in new code (unless you need access
from a language other than C++). This version of these functions
should also happily coexist with other versions, as the names
used are macros that expand to the actual function names.</i> <br>
</p>
<hr>
<p><i>Copyright </i><a href="mailto:John_Maddock@compuserve.com"><i>Dr
John Maddock</i></a><i> 1998-2000 all rights reserved.</i> </p>
</body>
</html>

Some files were not shown because too many files have changed in this diff Show More