mirror of
https://github.com/boostorg/regex.git
synced 2025-07-05 00:26:30 +02:00
1294 lines
30 KiB
HTML
1294 lines
30 KiB
HTML
![]() |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||
|
<html>
|
||
|
<head>
|
||
|
<title>Boost.Regex: basic_regex</title>
|
||
|
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
||
|
<meta http-equiv="Content-Type" content=
|
||
|
"text/html; charset=iso-8859-1">
|
||
|
<link rel="stylesheet" type="text/css" href="../../../boost.css">
|
||
|
</head>
|
||
|
<body>
|
||
|
<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>
|
||
|
|
||
|
<br>
|
||
|
<br>
|
||
|
|
||
|
|
||
|
<hr>
|
||
|
<h3>Synopsis</h3>
|
||
|
|
||
|
<pre>
|
||
|
#include <<a href="../../boost/regex.hpp">boost/regex.hpp</a>>
|
||
|
</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 behavior 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<charT></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> <<b>class</b> charT, <b>class</b> traits = regex_traits<charT>, <b>class</b> Allocator = std::allocator<charT> >
|
||
|
<b>class</b> basic_regex;
|
||
|
<b>typedef</b> basic_regex<<b>char</b>> regex;
|
||
|
<b>typedef</b> basic_regex<<b>wchar_t></b> wregex;
|
||
|
}
|
||
|
</pre>
|
||
|
|
||
|
<p>The definition of <i>basic_regex</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 <class charT,
|
||
|
class traits = regex_traits<charT>,
|
||
|
class Allocator = allocator<charT> >
|
||
|
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& a = Allocator());
|
||
|
explicit basic_regex(const charT* p, flag_type f = regex_constants::normal,
|
||
|
const Allocator& a = Allocator());
|
||
|
basic_regex(const charT* p1, const charT* p2, flag_type f = regex_constants::normal,
|
||
|
const Allocator& a = Allocator());
|
||
|
basic_regex(const charT* p, size_type len, flag_type f,
|
||
|
const Allocator& a = Allocator());
|
||
|
basic_regex(const basic_regex&);
|
||
|
template <class ST, class SA>
|
||
|
explicit basic_regex(const basic_string<charT, ST, SA>& p,
|
||
|
flag_type f = regex_constants::normal,
|
||
|
const Allocator& a = Allocator());
|
||
|
template <class InputIterator>
|
||
|
basic_regex(InputIterator first, inputIterator last,
|
||
|
flag_type f = regex_constants::normal,
|
||
|
const Allocator& a = Allocator());
|
||
|
|
||
|
~basic_regex();
|
||
|
basic_regex& operator=(const basic_regex&);
|
||
|
basic_regex& operator=(const charT* ptr);
|
||
|
template <class ST, class SA>
|
||
|
basic_regex& operator=(const basic_string<charT, ST, SA>& 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& assign(const basic_regex& that);
|
||
|
basic_regex& assign(const charT* ptr, flag_type f = regex_constants::normal);
|
||
|
basic_regex& assign(const charT* first, const charT* last,
|
||
|
flag_type f = regex_constants::normal);
|
||
|
template <class string_traits, class A>
|
||
|
basic_regex& assign(const basic_string<charT, string_traits, A>& s,
|
||
|
flag_type f = regex_constants::normal);
|
||
|
template <class InputIterator>
|
||
|
basic_regex& assign(InputIterator first, InputIterator last,
|
||
|
flag_type f = regex_constants::normal);
|
||
|
|
||
|
// const operations:
|
||
|
Allocator get_allocator() const;
|
||
|
flag_type getflags() const;
|
||
|
basic_string<charT> str() const;
|
||
|
int compare(basic_regex&) const;
|
||
|
// locale:
|
||
|
locale_type imbue(locale_type loc);
|
||
|
locale_type getloc() const;
|
||
|
// swap
|
||
|
void swap(basic_regex&) throw();
|
||
|
};
|
||
|
|
||
|
template <class charT, class traits, class Allocator>
|
||
|
bool operator == (const basic_regex<charT, traits, Allocator>& lhs,
|
||
|
const basic_regex<charT, traits, Allocator>& rhs);
|
||
|
template <class charT, class traits, class Allocator>
|
||
|
bool operator != (const basic_regex<charT, traits, Allocator>& lhs,
|
||
|
const basic_regex<charT, traits, Allocator>& rhs);
|
||
|
template <class charT, class traits, class Allocator>
|
||
|
bool operator < (const basic_regex<charT, traits, Allocator>& lhs,
|
||
|
const basic_regex<charT, traits, Allocator>& rhs);
|
||
|
template <class charT, class traits, class Allocator>
|
||
|
bool operator <= (const basic_regex<charT, traits, Allocator>& lhs,
|
||
|
const basic_regex<charT, traits, Allocator>& rhs);
|
||
|
template <class charT, class traits, class Allocator>
|
||
|
bool operator >= (const basic_regex<charT, traits, Allocator>& lhs,
|
||
|
const basic_regex<charT, traits, Allocator>& rhs);
|
||
|
template <class charT, class traits, class Allocator>
|
||
|
bool operator > (const basic_regex<charT, traits, Allocator>& lhs,
|
||
|
const basic_regex<charT, traits, Allocator>& rhs);
|
||
|
|
||
|
template <class charT, class io_traits, class re_traits, class Allocator>
|
||
|
basic_ostream<charT, io_traits>&
|
||
|
operator << (basic_ostream<charT, io_traits>& os,
|
||
|
const basic_regex<charT, re_traits, Allocator>& e);
|
||
|
|
||
|
template <class charT, class traits, class Allocator>
|
||
|
void swap(basic_regex<charT, traits, Allocator>& e1,
|
||
|
basic_regex<charT, traits, Allocator>& e2);
|
||
|
|
||
|
typedef basic_regex<char> regex;
|
||
|
typedef basic_regex<wchar_t> wregex;
|
||
|
|
||
|
} // namespace boost
|
||
|
</pre>
|
||
|
|
||
|
<h3>Description</h3>
|
||
|
|
||
|
<p>Class <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& a = Allocator());
|
||
|
</pre>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Effects:</b> Constructs an object of class <code>
|
||
|
basic_regex</code>. The postconditions of this function are
|
||
|
indicated in the table:</p>
|
||
|
|
||
|
<div align="center"><br align="center">
|
||
|
<br>
|
||
|
<center>
|
||
|
<table id="Table2" cellspacing="1" cellpadding="7" width="624"
|
||
|
border="1">
|
||
|
<tbody>
|
||
|
<tr>
|
||
|
<td valign="top" width="50%">
|
||
|
|
||
|
<p><b>Element</b></p>
|
||
|
</td>
|
||
|
<td valign="top" width="50%">
|
||
|
|
||
|
<p><b>Value</b></p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td valign="top" width="50%">
|
||
|
<p>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<charT>()</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
</center>
|
||
|
</div>
|
||
|
|
||
|
<pre>
|
||
|
|
||
|
</pre>
|
||
|
|
||
|
<pre>
|
||
|
basic_regex(const charT* p, flag_type f = regex_constants::normal, const Allocator& a = Allocator());
|
||
|
</pre>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Requires:</b> <i>p</i> shall not be a null pointer.</p>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Throws:</b> <code>bad_expression</code> if <i>p</i> is not a
|
||
|
valid regular expression.</p>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>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> specified
|
||
|
in <i>f</i>. The postconditions of this function are indicated in
|
||
|
the table:</p>
|
||
|
|
||
|
|
||
|
|
||
|
<div align="center"><br align="center">
|
||
|
<br>
|
||
|
<center>
|
||
|
<table id="Table3" cellspacing="1" cellpadding="7" width="624"
|
||
|
border="1">
|
||
|
<tbody>
|
||
|
<tr>
|
||
|
<td valign="top" width="50%">
|
||
|
|
||
|
<p><b>Element</b></p>
|
||
|
</td>
|
||
|
<td valign="top" width="50%">
|
||
|
|
||
|
<p><b>Value</b></p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td valign="top" width="50%">
|
||
|
<p>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<charT>::length(p)</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td valign="top" width="50%">
|
||
|
<p>str()</p>
|
||
|
</td>
|
||
|
<td valign="top" width="50%">
|
||
|
<p>basic_string<charT>(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>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
</center>
|
||
|
</div>
|
||
|
|
||
|
<pre>
|
||
|
|
||
|
</pre>
|
||
|
|
||
|
<pre>
|
||
|
basic_regex(const charT* p1, const charT* p2, flag_type f = regex_constants::normal, const Allocator& a = Allocator());
|
||
|
</pre>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Requires:</b> <i>p1</i> and <i>p2</i> are not null pointers,
|
||
|
<code>p1 < p2</code>.</p>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Throws:</b> <code>bad_expression</code> if [p1,p2) is not a
|
||
|
valid regular expression.</p>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>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>
|
||
|
|
||
|
|
||
|
|
||
|
<div align="center"><br align="center">
|
||
|
<br>
|
||
|
<center>
|
||
|
<table id="Table4" cellspacing="1" cellpadding="7" width="624"
|
||
|
border="1">
|
||
|
<tbody>
|
||
|
<tr>
|
||
|
<td valign="top" width="50%">
|
||
|
|
||
|
<p><b>Element</b></p>
|
||
|
</td>
|
||
|
<td valign="top" width="50%">
|
||
|
|
||
|
<p><b>Value</b></p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td valign="top" width="50%">
|
||
|
<p>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<charT>(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>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
</center>
|
||
|
</div>
|
||
|
|
||
|
<pre>
|
||
|
|
||
|
</pre>
|
||
|
|
||
|
<pre>
|
||
|
basic_regex(const charT* p, size_type len, flag_type f, const Allocator& a = Allocator());
|
||
|
</pre>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Requires:</b> <i>p</i> shall not be a null pointer, <code>len
|
||
|
< max_size()</code>.</p>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Throws:</b> <code>bad_expression</code> if <i>p</i> is not a
|
||
|
valid regular expression.</p>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>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>
|
||
|
|
||
|
|
||
|
|
||
|
<div align="center"><br align="center">
|
||
|
<br>
|
||
|
<center>
|
||
|
<table id="Table5" cellspacing="1" cellpadding="7" width="624"
|
||
|
border="1">
|
||
|
<tbody>
|
||
|
<tr>
|
||
|
<td valign="top" width="50%">
|
||
|
|
||
|
<p><b>Element</b></p>
|
||
|
</td>
|
||
|
<td valign="top" width="50%">
|
||
|
|
||
|
<p><b>Value</b></p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td valign="top" width="50%">
|
||
|
<p>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<charT>(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>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
</center>
|
||
|
</div>
|
||
|
|
||
|
<pre>
|
||
|
|
||
|
</pre>
|
||
|
|
||
|
<pre>
|
||
|
basic_regex(const basic_regex& e);
|
||
|
</pre>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>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>
|
||
|
|
||
|
|
||
|
|
||
|
<div align="center"><br align="center">
|
||
|
<br>
|
||
|
<center>
|
||
|
<table id="Table6" cellspacing="1" cellpadding="7" width="624"
|
||
|
border="1">
|
||
|
<tbody>
|
||
|
<tr>
|
||
|
<td valign="top" width="50%">
|
||
|
|
||
|
<p><b>Element</b></p>
|
||
|
</td>
|
||
|
<td valign="top" width="50%">
|
||
|
|
||
|
<p><b>Value</b></p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td valign="top" width="50%">
|
||
|
<p>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>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
</center>
|
||
|
</div>
|
||
|
|
||
|
<pre>
|
||
|
|
||
|
</pre>
|
||
|
|
||
|
<pre>
|
||
|
template <class ST, class SA>
|
||
|
basic_regex(const basic_string<charT, ST, SA>& s,
|
||
|
flag_type f = regex_constants::normal, const Allocator& a = Allocator());
|
||
|
</pre>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Throws:</b> <code>bad_expression</code> if <i>s</i> is not a
|
||
|
valid regular expression.</p>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>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>
|
||
|
|
||
|
|
||
|
|
||
|
<div align="center"><br align="center">
|
||
|
<br>
|
||
|
<center>
|
||
|
<table id="Table7" cellspacing="1" cellpadding="7" width="624"
|
||
|
border="1">
|
||
|
<tbody>
|
||
|
<tr>
|
||
|
<td valign="top" width="50%">
|
||
|
|
||
|
<p><b>Element</b></p>
|
||
|
</td>
|
||
|
<td valign="top" width="50%">
|
||
|
|
||
|
<p><b>Value</b></p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td valign="top" width="50%">
|
||
|
<p>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>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
</center>
|
||
|
</div>
|
||
|
|
||
|
<pre>
|
||
|
|
||
|
</pre>
|
||
|
|
||
|
<pre>
|
||
|
template <class ForwardIterator>
|
||
|
basic_regex(ForwardIterator first, ForwardIterator last,
|
||
|
flag_type f = regex_constants::normal, const Allocator& a = Allocator());
|
||
|
</pre>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Throws:</b> <code>bad_expression</code> if the sequence <i>
|
||
|
[first, last)</i> is not a valid regular expression.</p>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>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>
|
||
|
|
||
|
|
||
|
|
||
|
<div align="center"><br align="center">
|
||
|
<br>
|
||
|
<center>
|
||
|
<table id="Table8" cellspacing="1" cellpadding="7" width="624"
|
||
|
border="1">
|
||
|
<tbody>
|
||
|
<tr>
|
||
|
<td valign="top" width="50%">
|
||
|
|
||
|
<p><b>Element</b></p>
|
||
|
</td>
|
||
|
<td valign="top" width="50%">
|
||
|
|
||
|
<p><b>Value</b></p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td valign="top" width="50%">
|
||
|
<p>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<charT>(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>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
</center>
|
||
|
</div>
|
||
|
|
||
|
<pre>
|
||
|
|
||
|
</pre>
|
||
|
|
||
|
<pre>
|
||
|
basic_regex& operator=(const basic_regex& e);
|
||
|
</pre>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Effects:</b> Returns the result of <code>assign(e.str(),
|
||
|
e.getflags())</code>.</p>
|
||
|
|
||
|
<pre>
|
||
|
basic_regex& operator=(const charT* ptr);
|
||
|
</pre>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Requires:</b> <i>p</i> shall not be a null pointer.</p>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Effects:</b> Returns the result of <code>
|
||
|
assign(ptr)</code>.</p>
|
||
|
|
||
|
<pre>
|
||
|
template <class ST, class SA>
|
||
|
basic_regex& operator=(const basic_string<charT, ST, SA>& p);
|
||
|
</pre>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Effects:</b> Returns the result of <code>
|
||
|
assign(p)</code>.</p>
|
||
|
|
||
|
<h4>basic_regex iterators</h4>
|
||
|
|
||
|
<pre>
|
||
|
const_iterator begin() const;
|
||
|
</pre>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Effects:</b> Returns a starting iterator to a sequence of
|
||
|
characters representing the regular expression.</p>
|
||
|
|
||
|
<pre>
|
||
|
const_iterator end() const;
|
||
|
</pre>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>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>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Effects:</b> Returns the length of the sequence of characters
|
||
|
representing the regular expression.</p>
|
||
|
|
||
|
<pre>
|
||
|
size_type max_size() const;
|
||
|
</pre>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Effects:</b> Returns the maximum length of the sequence of
|
||
|
characters representing the regular expression.</p>
|
||
|
|
||
|
<pre>
|
||
|
bool empty() const;
|
||
|
</pre>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>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>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Effects:</b> Returns the number of marked sub-expressions
|
||
|
within the regular expresion.</p>
|
||
|
|
||
|
<h4>basic_regex assign</h4>
|
||
|
|
||
|
<pre>
|
||
|
basic_regex& assign(const basic_regex& that);
|
||
|
</pre>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Effects:</b> Returns <code>assign(that.str(),
|
||
|
that.getflags())</code>.</p>
|
||
|
|
||
|
<pre>
|
||
|
basic_regex& assign(const charT* ptr, flag_type f = regex_constants::normal);
|
||
|
</pre>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Effects:</b> Returns <code>assign(string_type(ptr),
|
||
|
f)</code>.</p>
|
||
|
|
||
|
<pre>
|
||
|
basic_regex& assign(const charT* first, const charT* last,
|
||
|
flag_type f = regex_constants::normal);
|
||
|
</pre>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Effects:</b> Returns <code>assign(string_type(first, last),
|
||
|
f)</code>.</p>
|
||
|
|
||
|
<pre>
|
||
|
template <class string_traits, class A>
|
||
|
basic_regex& assign(const basic_string<charT, string_traits, A>& s,
|
||
|
flag_type f = regex_constants::normal);
|
||
|
</pre>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Throws:</b> <code>bad_expression</code> if <i>s</i> is not a
|
||
|
valid regular expression.</p>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Returns:</b> <code>*this</code>.</p>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>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>
|
||
|
|
||
|
|
||
|
|
||
|
<div align="center"><br align="center">
|
||
|
<br>
|
||
|
<center>
|
||
|
<table id="Table9" cellspacing="1" cellpadding="7" width="624"
|
||
|
border="1">
|
||
|
<tbody>
|
||
|
<tr>
|
||
|
<td valign="top" width="50%">
|
||
|
|
||
|
<p><b>Element</b></p>
|
||
|
</td>
|
||
|
<td valign="top" width="50%">
|
||
|
|
||
|
<p><b>Value</b></p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td valign="top" width="50%">
|
||
|
<p>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>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
</center>
|
||
|
</div>
|
||
|
|
||
|
<pre>
|
||
|
|
||
|
</pre>
|
||
|
|
||
|
<pre>
|
||
|
template <class InputIterator>
|
||
|
basic_regex& assign(InputIterator first, InputIterator last,
|
||
|
flag_type f = regex_constants::normal);
|
||
|
</pre>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Requires:</b> The type InputIterator corresponds to the Input
|
||
|
Iterator requirements (24.1.1).</p>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Effects:</b> Returns <code>assign(string_type(first, last),
|
||
|
f)</code>.</p>
|
||
|
|
||
|
<h4>basic_regex constant operations</h4>
|
||
|
|
||
|
<pre>
|
||
|
Allocator get_allocator() const;
|
||
|
</pre>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Effects:</b> Returns a copy of the Allocator that was passed
|
||
|
to the object's constructor.</p>
|
||
|
|
||
|
<pre>
|
||
|
flag_type getflags() const;
|
||
|
</pre>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>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.</code></p>
|
||
|
|
||
|
<pre>
|
||
|
basic_string<charT> str() const;
|
||
|
</pre>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Effects:</b> Returns a copy of the character sequence passed
|
||
|
to the object's constructor, or the last call to <code>
|
||
|
assign.</code></p>
|
||
|
|
||
|
<pre>
|
||
|
int compare(basic_regex& e)const;
|
||
|
</pre>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>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>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>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>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Postcondition:</b> <code>empty() == true</code>.</p>
|
||
|
|
||
|
<pre>
|
||
|
locale_type getloc() const;
|
||
|
</pre>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>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& e) throw();
|
||
|
</pre>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Effects:</b> Swaps the contents of the two regular
|
||
|
expressions.</p>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>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>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Complexity:</b> constant time.</p>
|
||
|
|
||
|
<h4>basic_regex non-member functions</h4>
|
||
|
|
||
|
<h5>basic_regex non-member comparison operators </h5>
|
||
|
|
||
|
<pre>
|
||
|
template <class charT, class traits, class Allocator>
|
||
|
bool operator == (const basic_regex<charT, traits, Allocator>& lhs,
|
||
|
const basic_regex<charT, traits, Allocator>& rhs);
|
||
|
</pre>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Effects:</b> Returns <code>lhs.compare(rhs) == 0</code>.</p>
|
||
|
|
||
|
<pre>
|
||
|
template <class charT, class traits, class Allocator>
|
||
|
bool operator != (const basic_regex<charT, traits, Allocator>& lhs,
|
||
|
const basic_regex<charT, traits, Allocator>& rhs);
|
||
|
</pre>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Effects:</b> Returns <code>lhs.compare(rhs) != 0</code>.</p>
|
||
|
|
||
|
<pre>
|
||
|
template <class charT, class traits, class Allocator>
|
||
|
bool operator < (const basic_regex<charT, traits, Allocator>& lhs,
|
||
|
const basic_regex<charT, traits, Allocator>& rhs);
|
||
|
</pre>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Effects:</b> Returns <code>lhs.compare(rhs) <
|
||
|
0</code>.</p>
|
||
|
|
||
|
<pre>
|
||
|
template <class charT, class traits, class Allocator>
|
||
|
bool operator <= (const basic_regex<charT, traits, Allocator>& lhs,
|
||
|
const basic_regex<charT, traits, Allocator>& rhs);
|
||
|
</pre>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Effects:</b> Returns <code>lhs.compare(rhs) <=
|
||
|
0</code>.</p>
|
||
|
|
||
|
<pre>
|
||
|
template <class charT, class traits, class Allocator>
|
||
|
bool operator >= (const basic_regex<charT, traits, Allocator>& lhs,
|
||
|
const basic_regex<charT, traits, Allocator>& rhs);
|
||
|
</pre>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Effects:</b> Returns <code>lhs.compare(rhs) >=
|
||
|
0</code>.</p>
|
||
|
|
||
|
<pre>
|
||
|
template <class charT, class traits, class Allocator>
|
||
|
bool operator > (const basic_regex<charT, traits, Allocator>& lhs,
|
||
|
const basic_regex<charT, traits, Allocator>& rhs);
|
||
|
</pre>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Effects:</b> Returns <code>lhs.compare(rhs) >
|
||
|
0</code>.</p>
|
||
|
|
||
|
<h5>basic_regex inserter.</h5>
|
||
|
|
||
|
<pre>
|
||
|
template <class charT, class io_traits, class re_traits, class Allocator>
|
||
|
basic_ostream<charT, io_traits>&
|
||
|
operator << (basic_ostream<charT, io_traits>& os
|
||
|
const basic_regex<charT, re_traits, Allocator>& e);
|
||
|
</pre>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Effects:</b> Returns (os << e.str()).</p>
|
||
|
|
||
|
<h5>basic_regex non-member swap</h5>
|
||
|
|
||
|
<pre>
|
||
|
template <class charT, class traits, class Allocator>
|
||
|
void swap(basic_regex<charT, traits, Allocator>& lhs,
|
||
|
basic_regex<charT, traits, Allocator>& rhs);
|
||
|
</pre>
|
||
|
|
||
|
|
||
|
|
||
|
<p><b>Effects:</b> calls <code>lhs.swap(rhs)</code>.</p>
|
||
|
|
||
|
<hr>
|
||
|
<p>Revised
|
||
|
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
|
||
|
17 May 2003
|
||
|
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
|
||
|
|
||
|
<p><i>© Copyright <a href="mailto:jm@regex.fsnet.co.uk">John
|
||
|
Maddock</a> 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>
|
||
|
|
||
|
|