1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906
|
<!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="../../../boost.png" 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 two template parameters:</p>
<p><b><i>charT</i></b>: determines the character type, i.e. either char or
wchar_t; see <EM><A href="concepts.html#charT">charT concept</A></EM>.</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>. See
also <EM><A href="concepts.html#traits">traits concept</A></EM>.</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 non-standard
character types, 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> 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 basic_regex {
public:
// types:
typedef charT value_type;
typedef implementation-specific const_iterator;
typedef const_iterator iterator;
typedef charT& reference;
typedef const charT& const_reference;
typedef std::ptrdiff_t difference_type;
typedef std::size_t size_type;
typedef regex_constants::syntax_option_type flag_type;
typedef typename traits::locale_type locale_type;
// constants:
// main option selection:
static const regex_constants::syntax_option_type normal = regex_constants::normal;
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;
static const regex_constants::syntax_option_type literal = regex_constants::literal;
// modifiers specific to perl expressions:
static const regex_constants::syntax_option_type no_mod_m = regex_constants::no_mod_m;
static const regex_constants::syntax_option_type no_mod_s = regex_constants::no_mod_s;
static const regex_constants::syntax_option_type mod_s = regex_constants::mod_s;
static const regex_constants::syntax_option_type mod_x = regex_constants::mod_x;
// modifiers specific to POSIX basic expressions:
static const regex_constants::syntax_option_type bk_plus_qm = regex_constants::bk_plus_qm;
static const regex_constants::syntax_option_type bk_vbar = regex_constants::bk_vbar
static const regex_constants::syntax_option_type no_char_classes = regex_constants::no_char_classes
static const regex_constants::syntax_option_type no_intervals = regex_constants::no_intervals
// common modifiers:
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 newline_alt = regex_constants::newline_alt;
static const regex_constants::syntax_option_type no_except = regex_constants::newline_alt;
// construct/copy/destroy:
explicit <A href="#c1">basic_regex</A> ();
explicit <A href="#c2">basic_regex</A>(const charT* p, flag_type f = regex_constants::normal);
<A href="#c3">basic_regex</A>(const charT* p1, const charT* p2, flag_type f = regex_constants::normal);
<A href="#c4">basic_regex</A>(const charT* p, size_type len, flag_type f);
<A href="#c5">basic_regex</A>(const basic_regex&);
template <class ST, class SA>
explicit <A href="#c6">basic_regex</A>(const basic_string<charT, ST, SA>& p, flag_type f = regex_constants::normal);
template <class InputIterator>
<A href="#c7">basic_regex</A>(InputIterator first, InputIterator last, flag_type f = regex_constants::normal);
~basic_regex();
basic_regex& <A href="#o1">operator</A>=(const basic_regex&);
basic_regex& <A href="#o2">operator</A>= (const charT* ptr);
template <class ST, class SA>
basic_regex& <A href="#o3">operator</A>= (const basic_string<charT, ST, SA>& p);
// iterators:
const_iterator <A href="#m1">begin</A>() const;
const_iterator <A href="#m2">end</A>() const;
// capacity:
size_type <A href="#m3">size</A>() const;
size_type <A href="#m4">max_size</A>() const;
bool <A href="#m5">empty</A>() const;
unsigned <A href="#m6">mark_count</A>()const;
//
// modifiers:
basic_regex& <A href="#a1">assign</A>(const basic_regex& that);
basic_regex& <A href="#a2">assign</A>(const charT* ptr, flag_type f = regex_constants::normal);
basic_regex& <A href="#a3">assign</A>(const charT* ptr, unsigned int len, flag_type f);
template <class string_traits, class A>
basic_regex& <A href="#a4">assign</A>(const basic_string<charT, string_traits, A>& s,
flag_type f = regex_constants::normal);
template <class InputIterator>
basic_regex& <A href="#a5">assign</A>(InputIterator first, InputIterator last,
flag_type f = regex_constants::normal);
// const operations:
flag_type <A href="#m8">flags</A>() const;
int <A href="#m8b">status</A>()const;
basic_string<charT> <A href="#m9">str</A>() const;
int <A href="#m10">compare</A>(basic_regex&) const;
// locale:
locale_type <A href="#m11">imbue</A>(locale_type loc);
locale_type <A href="#m12">getloc</A>() const;
// swap
void <A href="#m13">swap</A>(basic_regex&) throw();
};
template <class charT, class traits>
bool <A href="#o4">operator</A> == (const basic_regex<charT, traits>& lhs,
const basic_regex<charT, traits>& rhs);
template <class charT, class traits>
bool <A href="#o5">operator</A> != (const basic_regex<charT, traits>& lhs,
const basic_regex<charT, traits>& rhs);
template <class charT, class traits>
bool <A href="#o7">operator</A> < (const basic_regex<charT, traits>& lhs,
const basic_regex<charT, traits>& rhs);
template <class charT, class traits>
bool <A href="#o8">operator</A> <= (const basic_regex<charT, traits>& lhs,
const basic_regex<charT, traits>& rhs);
template <class charT, class traits>
bool <A href="#o9">operator</A> >= (const basic_regex<charT, traits>& lhs,
const basic_regex<charT, traits>& rhs);
template <class charT, class traits>
bool <A href="#o10">operator</A> > (const basic_regex<charT, traits>& lhs,
const basic_regex<charT, traits>& rhs);
template <class charT, class io_traits, class re_traits>
basic_ostream<charT, io_traits>&
<A href="#o11">operator</A> << (basic_ostream<charT, io_traits>& os,
const basic_regex<charT, re_traits>& e);
template <class charT, class traits>
void <A href="#o12">swap</A>(basic_regex<charT, traits>& e1,
basic_regex<charT, traits>& 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>
// main option selection:
static const regex_constants::syntax_option_type normal = regex_constants::normal;
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 = regex_constants::sed;
static const regex_constants::syntax_option_type perl = regex_constants::perl;
static const regex_constants::syntax_option_type literal = regex_constants::literal;
// modifiers specific to perl expressions:
static const regex_constants::syntax_option_type no_mod_m = regex_constants::no_mod_m;
static const regex_constants::syntax_option_type no_mod_s = regex_constants::no_mod_s;
static const regex_constants::syntax_option_type mod_s = regex_constants::mod_s;
static const regex_constants::syntax_option_type mod_x = regex_constants::mod_x;
// modifiers specific to POSIX basic expressions:
static const regex_constants::syntax_option_type bk_plus_qm = regex_constants::bk_plus_qm;
static const regex_constants::syntax_option_type bk_vbar = regex_constants::bk_vbar
static const regex_constants::syntax_option_type no_char_classes = regex_constants::no_char_classes
static const regex_constants::syntax_option_type no_intervals = regex_constants::no_intervals
// common modifiers:
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 newline_alt = regex_constants::newline_alt;
</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><A href="syntax_option_type.html">
syntax_option_type</A></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>
<pre><A name=c1> basic_regex();
</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">
<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><A name=c2><BR> basic_regex(const charT* p, flag_type f = regex_constants::normal);
</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, unless the flag no_except is set in <EM>f</EM>.</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">
<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>flags()</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><A name=c3></A>basic_regex(const charT* p1, const charT* p2, flag_type f = regex_constants::normal);</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, unless the flag no_except is set in <EM>f</EM>.</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">
<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>flags()</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><A name=c4></A>basic_regex(const charT* p, size_type len, flag_type f);
</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, unless the flag no_except is set in <EM>f</EM>.</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">
<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>flags()</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><A name=c5></A><BR>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">
<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>flags()</p>
</td>
<td valign="top" width="50%">
<p>e.flags()</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><BR>
template <class ST, class SA>
<A name=c6></A>basic_regex(const basic_string<charT, ST, SA>& 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, unless the flag no_except is set in <EM>f</EM>.</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">
<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>flags()</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><BR>
template <class ForwardIterator>
<A name=c7></A>basic_regex(ForwardIterator first, ForwardIterator last, flag_type f = regex_constants::normal);
</pre>
<p><b>Throws:</b> <code>bad_expression</code> if the sequence <i>[first, last)</i>
is not a valid regular expression, unless the flag no_except is set in <EM>f</EM>.</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">
<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>flags()</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><A name=o1></A>
basic_regex& operator=(const basic_regex& e);
</pre>
<p><b>Effects:</b> Returns the result of <code>assign(e.str(), e.flags())</code>.</p>
<pre><A name=o2></A>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><A name=o3></A>
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><A name=m1>
const_iterator begin() const;
</pre>
<p><b>Effects:</b> Returns a starting iterator to a sequence of characters
representing the regular expression.</p>
<pre><A name=m2>
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><A name=m3>
size_type size() const;
</pre>
<p><b>Effects:</b> Returns the length of the sequence of characters representing
the regular expression.</p>
<pre><A name=m4>
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><A name=m5></A>
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><A name=m6></A>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><A name=a1>
basic_regex& assign(const basic_regex& that);
</pre>
<p><b>Effects:</b> Returns <code>assign(that.str(), that.flags())</code>.</p>
<pre><A name=a2></A>
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><A name=a3></A><A name=a3></A>basic_regex& assign(const charT* ptr, unsigned int len, flag_type f);</PRE>
<P><B>Effects:</B> Returns <CODE>assign(string_type(ptr, len), f)</CODE>.</P>
<PRE><A name=a4></A>template <class string_traits, class A>
<A name=a6></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, unless the flag no_except is set in <EM>f</EM>.</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">
<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>flags()</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><A name=a5></A>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><A name=m7></A><A name=m8></A>flag_type flags() 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>
<CODE>
<PRE><A name=m7></A><A name=m8></A><A name=m8b></A>int status() const;</PRE>
</CODE>
<P><STRONG>Effects</STRONG>: Returns zero if the expression contains a valid
regular expression, otherwise an <A href="error_type.html">error code</A>.
This member function is retained for use in environments that cannot use
exception handling.</P>
<pre><A name=m9></A>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><A name=m10></A>int compare(basic_regex& e)const;
</pre>
<p><b>Effects:</b> If <code>flags() == e.flags()</code> then returns <code>str().compare(e.str())</code>,
otherwise returns <code>flags() - e.flags()</code>.</p>
<h4>basic_regex locale</h4>
<pre><A name=m11></A>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><A name=m12></A>
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><A name=m13>
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>
<P>Comparisons between basic_regex objects are provided on an experimental basis:
please note that these are likely to be removed from the standard library
proposal, so use with care if you are writing portable code.</P>
<pre><A name=o4></A>
template <class charT, class traits>
bool operator == (const basic_regex<charT, traits>& lhs,
const basic_regex<charT, traits>& rhs);
</pre>
<p><b>Effects:</b> Returns <code>lhs.compare(rhs) == 0</code>.</p>
<pre><A name=o5></A>
template <class charT, class traits>
bool operator != (const basic_regex<charT, traits>& lhs,
const basic_regex<charT, traits>& rhs);
</pre>
<p><b>Effects:</b> Returns <code>lhs.compare(rhs) != 0</code>.</p>
<pre><A name=o7></A>
template <class charT, class traits>
bool operator < (const basic_regex<charT, traits>& lhs,
const basic_regex<charT, traits>& rhs);
</pre>
<p><b>Effects:</b> Returns <code>lhs.compare(rhs) < 0</code>.</p>
<pre><A name=o8></A>
template <class charT, class traits>
bool operator <= (const basic_regex<charT, traits>& lhs,
const basic_regex<charT, traits>& rhs);
</pre>
<p><b>Effects:</b> Returns <code>lhs.compare(rhs) <= 0</code>.</p>
<pre><A name=o9></A>
template <class charT, class traits>
bool operator >= (const basic_regex<charT, traits>& lhs,
const basic_regex<charT, traits>& rhs);
</pre>
<p><b>Effects:</b> Returns <code>lhs.compare(rhs) >= 0</code>.</p>
<pre><A name=o10></A>
template <class charT, class traits>
bool operator > (const basic_regex<charT, traits>& lhs,
const basic_regex<charT, traits>& rhs);
</pre>
<p><b>Effects:</b> Returns <code>lhs.compare(rhs) > 0</code>.</p>
<h5>basic_regex inserter.</h5>
<P>The basic_regex stream inserter is provided on an experimental basis, and
outputs the textual representation of the expression to the stream:</P>
<pre><A name=o11></A>
template <class charT, class io_traits, class re_traits>
basic_ostream<charT, io_traits>&
operator << (basic_ostream<charT, io_traits>& os
const basic_regex<charT, re_traits>& e);
</pre>
<p><b>Effects:</b> Returns (os << e.str()).</p>
<h5>basic_regex non-member swap</h5>
<pre><A name=o12></A>
template <class charT, class traits>
void swap(basic_regex<charT, traits>& lhs,
basic_regex<charT, traits>& rhs);
</pre>
<p><b>Effects:</b> calls <code>lhs.swap(rhs)</code>.</p>
<hr>
<p>Revised 7 Aug
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
2004
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
<p><i> Copyright John Maddock 1998-
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2004<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
<P><I>Use, modification and distribution are subject to the Boost Software License,
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
</body>
</html>
|