1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.0 Transitional//EN">
4 <title>Boost.Regex: basic_regex
</title>
5 <meta name=
"generator" content=
"HTML Tidy, see www.w3.org">
6 <meta http-equiv=
"Content-Type" content=
"text/html; charset=iso-8859-1">
7 <link rel=
"stylesheet" type=
"text/css" href=
"../../../boost.css">
10 <table id=
"Table1" cellspacing=
"1" cellpadding=
"1" width=
"100%" border=
"0">
12 <td valign=
"top" width=
"300">
13 <h3><a href=
"../../../index.htm"><img height=
"86" width=
"277" alt=
"C++ Boost" src=
"../../../boost.png" border=
"0"></a></h3>
16 <h1 align=
"center">Boost.Regex
</h1>
17 <h2 align=
"center">basic_regex
</h2>
20 <h3><a href=
"index.html"><img height=
"45" width=
"43" alt=
"Boost.Regex Index" src=
"uarrow.gif" border=
"0"></a></h3>
29 #include
<<a href=
"../../../boost/regex.hpp">boost/regex.hpp
</a>>
31 <p>The template class
<em>basic_regex
</em> encapsulates regular expression parsing
32 and compilation. The class takes two template parameters:
</p>
33 <p><b><i>charT
</i></b>: determines the character type, i.e. either char or
34 wchar_t; see
<EM><A href=
"concepts.html#charT">charT concept
</A></EM>.
</p>
35 <p><b><i>traits
</i></b>: determines the behavior of the character type, for
36 example which character class names are recognized. A default traits class is
37 provided:
<a href=
"regex_traits.html">regex_traits
<charT
></a>.
See
38 also
<EM><A href=
"concepts.html#traits">traits concept
</A></EM>.
</p>
39 <p>For ease of use there are two typedefs that define the two standard
<i>basic_regex
</i>
40 instances, unless you want to use custom traits classes or non-standard
41 character types, you won't need to use anything other than these:
</p>
43 <b>namespace
</b> boost{
44 <b>template
</b> <<b>class
</b> charT,
<b>class
</b> traits = regex_traits
<charT
> >
45 <b>class
</b> basic_regex;
46 <b>typedef
</b> basic_regex
<<b>char
</b>> regex;
47 <b>typedef
</b> basic_regex
<<b>wchar_t
></b> wregex;
50 <p>The definition of
<i>basic_regex
</i> follows: it is based very closely on class
51 basic_string, and fulfils the requirements for a constant-container of
<i>charT
</i>.
</p>
55 template
<class charT, class traits = regex_traits
<charT
> >
59 typedef charT value_type;
60 typedef implementation-specific const_iterator;
61 typedef const_iterator iterator;
62 typedef charT
& reference;
63 typedef const charT
& const_reference;
64 typedef std::ptrdiff_t difference_type;
65 typedef std::size_t size_type;
66 typedef regex_constants::syntax_option_type flag_type;
67 typedef typename traits::locale_type locale_type;
70 // main option selection:
71 static const regex_constants::syntax_option_type normal = regex_constants::normal;
72 static const regex_constants::syntax_option_type ECMAScript = normal;
73 static const regex_constants::syntax_option_type JavaScript = normal;
74 static const regex_constants::syntax_option_type JScript = normal;
75 static const regex_constants::syntax_option_type basic = regex_constants::basic;
76 static const regex_constants::syntax_option_type extended = regex_constants::extended;
77 static const regex_constants::syntax_option_type awk = regex_constants::awk;
78 static const regex_constants::syntax_option_type grep = regex_constants::grep;
79 static const regex_constants::syntax_option_type egrep = regex_constants::egrep;
80 static const regex_constants::syntax_option_type sed = basic = regex_constants::sed;
81 static const regex_constants::syntax_option_type perl = regex_constants::perl;
82 static const regex_constants::syntax_option_type literal = regex_constants::literal;
83 // modifiers specific to perl expressions:
84 static const regex_constants::syntax_option_type no_mod_m = regex_constants::no_mod_m;
85 static const regex_constants::syntax_option_type no_mod_s = regex_constants::no_mod_s;
86 static const regex_constants::syntax_option_type mod_s = regex_constants::mod_s;
87 static const regex_constants::syntax_option_type mod_x = regex_constants::mod_x;
88 // modifiers specific to POSIX basic expressions:
89 static const regex_constants::syntax_option_type bk_plus_qm = regex_constants::bk_plus_qm;
90 static const regex_constants::syntax_option_type bk_vbar = regex_constants::bk_vbar
91 static const regex_constants::syntax_option_type no_char_classes = regex_constants::no_char_classes
92 static const regex_constants::syntax_option_type no_intervals = regex_constants::no_intervals
94 static const regex_constants::syntax_option_type nosubs = regex_constants::nosubs;
95 static const regex_constants::syntax_option_type optimize = regex_constants::optimize;
96 static const regex_constants::syntax_option_type collate = regex_constants::collate;
97 static const regex_constants::syntax_option_type newline_alt = regex_constants::newline_alt;
98 static const regex_constants::syntax_option_type no_except = regex_constants::newline_alt;
100 // construct/copy/destroy:
101 explicit
<A href=
"#c1">basic_regex
</A> ();
102 explicit
<A href=
"#c2">basic_regex
</A>(const charT* p, flag_type f = regex_constants::normal);
103 <A href=
"#c3">basic_regex
</A>(const charT* p1, const charT* p2, flag_type f = regex_constants::normal);
104 <A href=
"#c4">basic_regex
</A>(const charT* p, size_type len, flag_type f);
105 <A href=
"#c5">basic_regex
</A>(const basic_regex
&);
106 template
<class ST, class SA
>
107 explicit
<A href=
"#c6">basic_regex
</A>(const basic_string
<charT, ST, SA
>& p, flag_type f = regex_constants::normal);
108 template
<class InputIterator
>
109 <A href=
"#c7">basic_regex
</A>(InputIterator first, InputIterator last, flag_type f = regex_constants::normal);
112 basic_regex
& <A href=
"#o1">operator
</A>=(const basic_regex
&);
113 basic_regex
& <A href=
"#o2">operator
</A>= (const charT* ptr);
114 template
<class ST, class SA
>
115 basic_regex
& <A href=
"#o3">operator
</A>= (const basic_string
<charT, ST, SA
>& p);
117 const_iterator
<A href=
"#m1">begin
</A>() const;
118 const_iterator
<A href=
"#m2">end
</A>() const;
120 size_type
<A href=
"#m3">size
</A>() const;
121 size_type
<A href=
"#m4">max_size
</A>() const;
122 bool
<A href=
"#m5">empty
</A>() const;
123 unsigned
<A href=
"#m6">mark_count
</A>()const;
126 basic_regex
& <A href=
"#a1">assign
</A>(const basic_regex
& that);
127 basic_regex
& <A href=
"#a2">assign
</A>(const charT* ptr, flag_type f = regex_constants::normal);
128 basic_regex
& <A href=
"#a3">assign
</A>(const charT* ptr, unsigned int len, flag_type f);
129 template
<class string_traits, class A
>
130 basic_regex
& <A href=
"#a4">assign
</A>(const basic_string
<charT, string_traits, A
>& s,
131 flag_type f = regex_constants::normal);
132 template
<class InputIterator
>
133 basic_regex
& <A href=
"#a5">assign
</A>(InputIterator first, InputIterator last,
134 flag_type f = regex_constants::normal);
137 flag_type
<A href=
"#m8">flags
</A>() const;
138 int
<A href=
"#m8b">status
</A>()const;
139 basic_string
<charT
> <A href=
"#m9">str
</A>() const;
140 int
<A href=
"#m10">compare
</A>(basic_regex
&) const;
142 locale_type
<A href=
"#m11">imbue
</A>(locale_type loc);
143 locale_type
<A href=
"#m12">getloc
</A>() const;
145 void
<A href=
"#m13">swap
</A>(basic_regex
&) throw();
148 template
<class charT, class traits
>
149 bool
<A href=
"#o4">operator
</A> == (const basic_regex
<charT, traits
>& lhs,
150 const basic_regex
<charT, traits
>& rhs);
151 template
<class charT, class traits
>
152 bool
<A href=
"#o5">operator
</A> != (const basic_regex
<charT, traits
>& lhs,
153 const basic_regex
<charT, traits
>& rhs);
154 template
<class charT, class traits
>
155 bool
<A href=
"#o7">operator
</A> < (const basic_regex
<charT, traits
>& lhs,
156 const basic_regex
<charT, traits
>& rhs);
157 template
<class charT, class traits
>
158 bool
<A href=
"#o8">operator
</A> <= (const basic_regex
<charT, traits
>& lhs,
159 const basic_regex
<charT, traits
>& rhs);
160 template
<class charT, class traits
>
161 bool
<A href=
"#o9">operator
</A> >= (const basic_regex
<charT, traits
>& lhs,
162 const basic_regex
<charT, traits
>& rhs);
163 template
<class charT, class traits
>
164 bool
<A href=
"#o10">operator
</A> > (const basic_regex
<charT, traits
>& lhs,
165 const basic_regex
<charT, traits
>& rhs);
167 template
<class charT, class io_traits, class re_traits
>
168 basic_ostream
<charT, io_traits
>&
169 <A href=
"#o11">operator
</A> << (basic_ostream
<charT, io_traits
>& os,
170 const basic_regex
<charT, re_traits
>& e);
172 template
<class charT, class traits
>
173 void
<A href=
"#o12">swap
</A>(basic_regex
<charT, traits
>& e1,
174 basic_regex
<charT, traits
>& e2);
176 typedef basic_regex
<char
> regex;
177 typedef basic_regex
<wchar_t
> wregex;
182 <p>Class
<em>basic_regex
</em> has the following public member functions:
</p>
183 <h4>basic_regex constants
</h4>
185 // main option selection:
186 static const regex_constants::syntax_option_type normal = regex_constants::normal;
187 static const regex_constants::syntax_option_type ECMAScript = normal;
188 static const regex_constants::syntax_option_type JavaScript = normal;
189 static const regex_constants::syntax_option_type JScript = normal;
190 static const regex_constants::syntax_option_type basic = regex_constants::basic;
191 static const regex_constants::syntax_option_type extended = regex_constants::extended;
192 static const regex_constants::syntax_option_type awk = regex_constants::awk;
193 static const regex_constants::syntax_option_type grep = regex_constants::grep;
194 static const regex_constants::syntax_option_type egrep = regex_constants::egrep;
195 static const regex_constants::syntax_option_type sed = regex_constants::sed;
196 static const regex_constants::syntax_option_type perl = regex_constants::perl;
197 static const regex_constants::syntax_option_type literal = regex_constants::literal;
198 // modifiers specific to perl expressions:
199 static const regex_constants::syntax_option_type no_mod_m = regex_constants::no_mod_m;
200 static const regex_constants::syntax_option_type no_mod_s = regex_constants::no_mod_s;
201 static const regex_constants::syntax_option_type mod_s = regex_constants::mod_s;
202 static const regex_constants::syntax_option_type mod_x = regex_constants::mod_x;
203 // modifiers specific to POSIX basic expressions:
204 static const regex_constants::syntax_option_type bk_plus_qm = regex_constants::bk_plus_qm;
205 static const regex_constants::syntax_option_type bk_vbar = regex_constants::bk_vbar
206 static const regex_constants::syntax_option_type no_char_classes = regex_constants::no_char_classes
207 static const regex_constants::syntax_option_type no_intervals = regex_constants::no_intervals
209 static const regex_constants::syntax_option_type nosubs = regex_constants::nosubs;
210 static const regex_constants::syntax_option_type optimize = regex_constants::optimize;
211 static const regex_constants::syntax_option_type collate = regex_constants::collate;
212 static const regex_constants::syntax_option_type newline_alt = regex_constants::newline_alt;
214 <p>The static constant members are provided as synonyms for the constants declared
215 in namespace
<code>boost::regex_constants
</code>; for each constant of type
<code><A href=
"syntax_option_type.html">
216 syntax_option_type
</A></code> declared in namespace
<code>boost::regex_constants
</code>
217 then a constant with the same name, type and value is declared within the scope
218 of
<code>basic_regex
</code>.
</p>
219 <h4>basic_regex constructors
</h4>
220 <pre><A name=c1
> basic_regex();
222 <P><b>Effects:
</b> Constructs an object of class
<code>basic_regex
</code>. The
223 postconditions of this function are indicated in the table:
</P>
226 <table id=
"Table2" cellspacing=
"1" cellpadding=
"7" width=
"624" border=
"1">
229 <td valign=
"top" width=
"50%">
230 <p><b>Element
</b></p>
232 <td valign=
"top" width=
"50%">
237 <td valign=
"top" width=
"50%">
240 <td valign=
"top" width=
"50%">
245 <td valign=
"top" width=
"50%">
248 <td valign=
"top" width=
"50%">
253 <td valign=
"top" width=
"50%">
256 <td valign=
"top" width=
"50%">
257 <p>basic_string
<charT
>()
</p>
264 <pre><A name=c2
><BR> basic_regex(const charT* p, flag_type f = regex_constants::normal);
267 <P><b>Requires:
</b> <i>p
</i> shall not be a null pointer.
</P>
268 <p><b>Throws:
</b> <code>bad_expression
</code> if
<i>p
</i> is not a valid regular
269 expression, unless the flag no_except is set in
<EM>f
</EM>.
</p>
270 <p><b>Effects:
</b> Constructs an object of class
<code>basic_regex
</code>; the
271 object's internal finite state machine is constructed from the regular
272 expression contained in the null-terminated string
<i>p
</i>, and interpreted
273 according to the
<a href=
"syntax_option_type.html">option flags
</a> specified
274 in
<i>f
</i>. The postconditions of this function are indicated in the table:
</p>
277 <table id=
"Table3" cellspacing=
"1" cellpadding=
"7" width=
"624" border=
"1">
280 <td valign=
"top" width=
"50%">
281 <p><b>Element
</b></p>
283 <td valign=
"top" width=
"50%">
288 <td valign=
"top" width=
"50%">
291 <td valign=
"top" width=
"50%">
296 <td valign=
"top" width=
"50%">
299 <td valign=
"top" width=
"50%">
300 <p>char_traits
<charT
>::length(p)
</p>
304 <td valign=
"top" width=
"50%">
307 <td valign=
"top" width=
"50%">
308 <p>basic_string
<charT
>(p)
</p>
312 <td valign=
"top" width=
"50%">
315 <td valign=
"top" width=
"50%">
320 <td valign=
"top" width=
"50%">
323 <td valign=
"top" width=
"50%">
324 <p>The number of marked sub-expressions within the expression.
</p>
334 <PRE><A name=c3
></A>basic_regex(const charT* p1, const charT* p2, flag_type f = regex_constants::normal);
</PRE>
335 <p><b>Requires:
</b> <i>p1
</i> and
<i>p2
</i> are not null pointers,
<code>p1
< p2
</code>.
</p>
336 <p><b>Throws:
</b> <code>bad_expression
</code> if [p1,p2) is not a valid regular
337 expression, unless the flag no_except is set in
<EM>f
</EM>.
</p>
338 <p><b>Effects:
</b> Constructs an object of class
<code>basic_regex
</code>; the
339 object's internal finite state machine is constructed from the regular
340 expression contained in the sequence of characters [p1,p2), and interpreted
341 according the
<a href=
"syntax_option_type.html">option flags
</a> specified in
<i>f
</i>.
342 The postconditions of this function are indicated in the table:
</p>
345 <table id=
"Table4" cellspacing=
"1" cellpadding=
"7" width=
"624" border=
"1">
348 <td valign=
"top" width=
"50%">
349 <p><b>Element
</b></p>
351 <td valign=
"top" width=
"50%">
356 <td valign=
"top" width=
"50%">
359 <td valign=
"top" width=
"50%">
364 <td valign=
"top" width=
"50%">
367 <td valign=
"top" width=
"50%">
368 <p>std::distance(p1,p2)
</p>
372 <td valign=
"top" width=
"50%">
375 <td valign=
"top" width=
"50%">
376 <p>basic_string
<charT
>(p1,p2)
</p>
380 <td valign=
"top" width=
"50%">
383 <td valign=
"top" width=
"50%">
388 <td valign=
"top" width=
"50%">
391 <td valign=
"top" width=
"50%">
392 <p>The number of marked sub-expressions within the expression.
</p>
402 <pre><A name=c4
></A>basic_regex(const charT* p, size_type len, flag_type f);
404 <p><b>Requires:
</b> <i>p
</i> shall not be a null pointer,
<code>len
< max_size()
</code>.
</p>
405 <p><b>Throws:
</b> <code>bad_expression
</code> if
<i>p
</i> is not a valid regular
406 expression, unless the flag no_except is set in
<EM>f
</EM>.
</p>
407 <p><b>Effects:
</b> Constructs an object of class
<code>basic_regex
</code>; the
408 object's internal finite state machine is constructed from the regular
409 expression contained in the sequence of characters [p, p+len), and interpreted
410 according the
<a href=
"syntax_option_type.html">option flags
</a> specified in
<i>f
</i>.
411 The postconditions of this function are indicated in the table:
</p>
414 <table id=
"Table5" cellspacing=
"1" cellpadding=
"7" width=
"624" border=
"1">
417 <td valign=
"top" width=
"50%">
418 <p><b>Element
</b></p>
420 <td valign=
"top" width=
"50%">
425 <td valign=
"top" width=
"50%">
428 <td valign=
"top" width=
"50%">
433 <td valign=
"top" width=
"50%">
436 <td valign=
"top" width=
"50%">
441 <td valign=
"top" width=
"50%">
444 <td valign=
"top" width=
"50%">
445 <p>basic_string
<charT
>(p, len)
</p>
449 <td valign=
"top" width=
"50%">
452 <td valign=
"top" width=
"50%">
457 <td valign=
"top" width=
"50%">
460 <td valign=
"top" width=
"50%">
461 <p>The number of marked sub-expressions within the expression.
</p>
468 <pre><A name=c5
></A><BR>basic_regex(const basic_regex
& e);
470 <p><b>Effects:
</b> Constructs an object of class
<code>basic_regex
</code> as a
471 copy of the object
<i>e
</i>. The postconditions of this function are indicated
475 <table id=
"Table6" cellspacing=
"1" cellpadding=
"7" width=
"624" border=
"1">
478 <td valign=
"top" width=
"50%">
479 <p><b>Element
</b></p>
481 <td valign=
"top" width=
"50%">
486 <td valign=
"top" width=
"50%">
489 <td valign=
"top" width=
"50%">
494 <td valign=
"top" width=
"50%">
497 <td valign=
"top" width=
"50%">
502 <td valign=
"top" width=
"50%">
505 <td valign=
"top" width=
"50%">
510 <td valign=
"top" width=
"50%">
513 <td valign=
"top" width=
"50%">
518 <td valign=
"top" width=
"50%">
521 <td valign=
"top" width=
"50%">
522 <p>e.mark_count()
</p>
530 template
<class ST, class SA
>
531 <A name=c6
></A>basic_regex(const basic_string
<charT, ST, SA
>& s, flag_type f = regex_constants::normal);
533 <p><b>Throws:
</b> <code>bad_expression
</code> if
<i>s
</i> is not a valid regular
534 expression, unless the flag no_except is set in
<EM>f
</EM>.
</p>
535 <p><b>Effects:
</b> Constructs an object of class
<code>basic_regex
</code>; the
536 object's internal finite state machine is constructed from the regular
537 expression contained in the string
<i>s
</i>, and interpreted according to the
<a href=
"syntax_option_type.html">
538 option flags
</a> specified in
<i>f
</i>. The postconditions of this function
539 are indicated in the table:
</p>
542 <table id=
"Table7" cellspacing=
"1" cellpadding=
"7" width=
"624" border=
"1">
545 <td valign=
"top" width=
"50%">
546 <p><b>Element
</b></p>
548 <td valign=
"top" width=
"50%">
553 <td valign=
"top" width=
"50%">
556 <td valign=
"top" width=
"50%">
561 <td valign=
"top" width=
"50%">
564 <td valign=
"top" width=
"50%">
569 <td valign=
"top" width=
"50%">
572 <td valign=
"top" width=
"50%">
577 <td valign=
"top" width=
"50%">
580 <td valign=
"top" width=
"50%">
585 <td valign=
"top" width=
"50%">
588 <td valign=
"top" width=
"50%">
589 <p>The number of marked sub-expressions within the expression.
</p>
597 template
<class ForwardIterator
>
598 <A name=c7
></A>basic_regex(ForwardIterator first, ForwardIterator last, flag_type f = regex_constants::normal);
600 <p><b>Throws:
</b> <code>bad_expression
</code> if the sequence
<i>[first, last)
</i>
601 is not a valid regular expression, unless the flag no_except is set in
<EM>f
</EM>.
</p>
602 <p><b>Effects:
</b> Constructs an object of class
<code>basic_regex
</code>; the
603 object's internal finite state machine is constructed from the regular
604 expression contained in the sequence of characters [first, last), and
605 interpreted according to the
<a href=
"syntax_option_type.html">option flags
</a>
606 specified in
<i>f
</i>. The postconditions of this function are indicated in the
610 <table id=
"Table8" cellspacing=
"1" cellpadding=
"7" width=
"624" border=
"1">
613 <td valign=
"top" width=
"50%">
614 <p><b>Element
</b></p>
616 <td valign=
"top" width=
"50%">
621 <td valign=
"top" width=
"50%">
624 <td valign=
"top" width=
"50%">
629 <td valign=
"top" width=
"50%">
632 <td valign=
"top" width=
"50%">
633 <p>distance(first,last)
</p>
637 <td valign=
"top" width=
"50%">
640 <td valign=
"top" width=
"50%">
641 <p>basic_string
<charT
>(first,last)
</p>
645 <td valign=
"top" width=
"50%">
648 <td valign=
"top" width=
"50%">
653 <td valign=
"top" width=
"50%">
656 <td valign=
"top" width=
"50%">
657 <p>The number of marked sub-expressions within the expression.
</p>
665 basic_regex
& operator=(const basic_regex
& e);
667 <p><b>Effects:
</b> Returns the result of
<code>assign(e.str(), e.flags())
</code>.
</p>
668 <pre><A name=o2
></A>basic_regex
& operator=(const charT* ptr);
670 <p><b>Requires:
</b> <i>p
</i> shall not be a null pointer.
</p>
671 <p><b>Effects:
</b> Returns the result of
<code>assign(ptr)
</code>.
</p>
673 template
<class ST, class SA
>
674 basic_regex
& operator=(const basic_string
<charT, ST, SA
>& p);
676 <p><b>Effects:
</b> Returns the result of
<code>assign(p)
</code>.
</p>
677 <h4>basic_regex iterators
</h4>
679 const_iterator begin() const;
681 <p><b>Effects:
</b> Returns a starting iterator to a sequence of characters
682 representing the regular expression.
</p>
684 const_iterator end() const;
686 <p><b>Effects:
</b> Returns termination iterator to a sequence of characters
687 representing the regular expression.
</p>
688 <h4>basic_regex capacity
</h4>
690 size_type size() const;
692 <p><b>Effects:
</b> Returns the length of the sequence of characters representing
693 the regular expression.
</p>
695 size_type max_size() const;
697 <p><b>Effects:
</b> Returns the maximum length of the sequence of characters
698 representing the regular expression.
</p>
702 <p><b>Effects:
</b> Returns
<b>true
</b> if the object does not contain a valid
703 regular expression, otherwise
<b>false
</b>.
</p>
704 <pre><A name=m6
></A>unsigned mark_count() const;
706 <p><b>Effects:
</b> Returns the number of marked sub-expressions within the regular
708 <h4>basic_regex assign
</h4>
710 basic_regex
& assign(const basic_regex
& that);
712 <p><b>Effects:
</b> Returns
<code>assign(that.str(), that.flags())
</code>.
</p>
714 basic_regex
& assign(const charT* ptr, flag_type f = regex_constants::normal);
716 <p><b>Effects:
</b> Returns
<code>assign(string_type(ptr), f)
</code>.
</p>
717 <PRE><A name=a3
></A><A name=a3
></A>basic_regex
& assign(const charT* ptr, unsigned int len, flag_type f);
</PRE>
718 <P><B>Effects:
</B> Returns
<CODE>assign(string_type(ptr, len), f)
</CODE>.
</P>
719 <PRE><A name=a4
></A>template
<class string_traits, class A
>
720 <A name=a6
></A>basic_regex
& assign(const basic_string
<charT, string_traits, A
>& s,
721 flag_type f = regex_constants::normal);
723 <p><b>Throws:
</b> <code>bad_expression
</code> if
<i>s
</i> is not a valid regular
724 expression, unless the flag no_except is set in
<EM>f
</EM>.
</p>
725 <p><b>Returns:
</b> <code>*this
</code>.
</p>
726 <p><b>Effects:
</b> Assigns the regular expression contained in the string
<i>s
</i>,
727 interpreted according the
<a href=
"syntax_option_type.html">option flags
</a> specified
728 in
<i>f
</i>. The postconditions of this function are indicated in the table:
</p>
731 <table id=
"Table9" cellspacing=
"1" cellpadding=
"7" width=
"624" border=
"1">
734 <td valign=
"top" width=
"50%">
735 <p><b>Element
</b></p>
737 <td valign=
"top" width=
"50%">
742 <td valign=
"top" width=
"50%">
745 <td valign=
"top" width=
"50%">
750 <td valign=
"top" width=
"50%">
753 <td valign=
"top" width=
"50%">
758 <td valign=
"top" width=
"50%">
761 <td valign=
"top" width=
"50%">
766 <td valign=
"top" width=
"50%">
769 <td valign=
"top" width=
"50%">
774 <td valign=
"top" width=
"50%">
777 <td valign=
"top" width=
"50%">
778 <p>The number of marked sub-expressions within the expression.
</p>
788 <pre><A name=a5
></A>template
<class InputIterator
>
789 basic_regex
& assign(InputIterator first, InputIterator last,
790 flag_type f = regex_constants::normal);
792 <p><b>Requires:
</b> The type InputIterator corresponds to the Input Iterator
793 requirements (
24.1.1).
</p>
794 <p><b>Effects:
</b> Returns
<code>assign(string_type(first, last), f)
</code>.
</p>
795 <h4>basic_regex constant operations
</h4>
796 <pre><A name=m7
></A><A name=m8
></A>flag_type flags() const;
798 <p><b>Effects:
</b> Returns a copy of the regular expression syntax flags that were
799 passed to the object's constructor, or the last call to
<code>assign.
</code></p>
801 <PRE><A name=m7
></A><A name=m8
></A><A name=m8b
></A>int status() const;
</PRE>
803 <P><STRONG>Effects
</STRONG>: Returns zero if the expression contains a valid
804 regular expression, otherwise an
<A href=
"error_type.html">error code
</A>.
805 This member function is retained for use in environments that cannot use
806 exception handling.
</P>
807 <pre><A name=m9
></A>basic_string
<charT
> str() const;
809 <p><b>Effects:
</b> Returns a copy of the character sequence passed to the object's
810 constructor, or the last call to
<code>assign.
</code></p>
811 <pre><A name=m10
></A>int compare(basic_regex
& e)const;
813 <p><b>Effects:
</b> If
<code>flags() == e.flags()
</code> then returns
<code>str().compare(e.str())
</code>,
814 otherwise returns
<code>flags() - e.flags()
</code>.
</p>
815 <h4>basic_regex locale
</h4>
816 <pre><A name=m11
></A>locale_type imbue(locale_type l);
818 <p><b>Effects:
</b> Returns the result of
<code>traits_inst.imbue(l)
</code> where
<code>
819 traits_inst
</code> is a (default initialized) instance of the template
820 parameter
<code>traits
</code> stored within the object. Calls to imbue
821 invalidate any currently contained regular expression.
</p>
822 <p><b>Postcondition:
</b> <code>empty() == true
</code>.
</p>
823 <pre><A name=m12
></A>
824 locale_type getloc() const;
826 <p><b>Effects:
</b> Returns the result of
<code>traits_inst.getloc()
</code> where
<code>
827 traits_inst
</code> is a (default initialized) instance of the template
828 parameter
<code>traits
</code> stored within the object.
</p>
829 <h4>basic_regex swap
</h4>
831 void swap(basic_regex
& e) throw();
833 <p><b>Effects:
</b> Swaps the contents of the two regular expressions.
</p>
834 <p><b>Postcondition:
</b> <code>*this
</code> contains the characters that were in
<i>e
</i>,
835 <i>e
</i> contains the regular expression that was in
<code>*this
</code>.
</p>
836 <p><b>Complexity:
</b> constant time.
</p>
837 <h4>basic_regex non-member functions
</h4>
838 <h5>basic_regex non-member comparison operators
</h5>
839 <P>Comparisons between basic_regex objects are provided on an experimental basis:
840 please note that these are likely to be removed from the standard library
841 proposal, so use with care if you are writing portable code.
</P>
843 template
<class charT, class traits
>
844 bool operator == (const basic_regex
<charT, traits
>& lhs,
845 const basic_regex
<charT, traits
>& rhs);
847 <p><b>Effects:
</b> Returns
<code>lhs.compare(rhs) ==
0</code>.
</p>
849 template
<class charT, class traits
>
850 bool operator != (const basic_regex
<charT, traits
>& lhs,
851 const basic_regex
<charT, traits
>& rhs);
853 <p><b>Effects:
</b> Returns
<code>lhs.compare(rhs) !=
0</code>.
</p>
855 template
<class charT, class traits
>
856 bool operator
< (const basic_regex
<charT, traits
>& lhs,
857 const basic_regex
<charT, traits
>& rhs);
859 <p><b>Effects:
</b> Returns
<code>lhs.compare(rhs)
< 0</code>.
</p>
861 template
<class charT, class traits
>
862 bool operator
<= (const basic_regex
<charT, traits
>& lhs,
863 const basic_regex
<charT, traits
>& rhs);
865 <p><b>Effects:
</b> Returns
<code>lhs.compare(rhs)
<=
0</code>.
</p>
867 template
<class charT, class traits
>
868 bool operator
>= (const basic_regex
<charT, traits
>& lhs,
869 const basic_regex
<charT, traits
>& rhs);
871 <p><b>Effects:
</b> Returns
<code>lhs.compare(rhs)
>=
0</code>.
</p>
872 <pre><A name=o10
></A>
873 template
<class charT, class traits
>
874 bool operator
> (const basic_regex
<charT, traits
>& lhs,
875 const basic_regex
<charT, traits
>& rhs);
877 <p><b>Effects:
</b> Returns
<code>lhs.compare(rhs)
> 0</code>.
</p>
878 <h5>basic_regex inserter.
</h5>
879 <P>The basic_regex stream inserter is provided on an experimental basis, and
880 outputs the textual representation of the expression to the stream:
</P>
881 <pre><A name=o11
></A>
882 template
<class charT, class io_traits, class re_traits
>
883 basic_ostream
<charT, io_traits
>&
884 operator
<< (basic_ostream
<charT, io_traits
>& os
885 const basic_regex
<charT, re_traits
>& e);
887 <p><b>Effects:
</b> Returns (os
<< e.str()).
</p>
888 <h5>basic_regex non-member swap
</h5>
889 <pre><A name=o12
></A>
890 template
<class charT, class traits
>
891 void swap(basic_regex
<charT, traits
>& lhs,
892 basic_regex
<charT, traits
>& rhs);
894 <p><b>Effects:
</b> calls
<code>lhs.swap(rhs)
</code>.
</p>
897 <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
899 <!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
900 <p><i>© Copyright John Maddock
1998-
901 <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2004<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
902 <P><I>Use, modification and distribution are subject to the Boost Software License,
903 Version
1.0. (See accompanying file
<A href=
"../../../LICENSE_1_0.txt">LICENSE_1_0.txt
</A>
904 or copy at
<A href=
"http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt
</A>)
</I></P>