...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::xpressive::basic_regex — Class template basic_regex<> is a class for holding a compiled regular expression.
// In header: <boost/xpressive/basic_regex.hpp> template<typename BidiIter> struct basic_regex { // types typedef BidiIter iterator_type; typedef iterator_value< BidiIter >::type char_type; typedef iterator_value< BidiIter >::type value_type; typedef unspecified string_type; typedef regex_constants::syntax_option_type flag_type; // public member functions basic_regex(); basic_regex(basic_regex< BidiIter > const &); basic_regex< BidiIter > & operator=(basic_regex< BidiIter > const &); template<typename Expr> basic_regex(Expr const &); template<typename Expr> basic_regex< BidiIter > & operator=(Expr const &); std::size_t mark_count() const; regex_id_type regex_id() const; void swap(basic_regex< BidiIter > &); // public static functions template<typename InputIter> static basic_regex< BidiIter > compile(InputIter, InputIter, flag_type = regex_constants::ECMAScript); template<typename InputRange> static basic_regex< BidiIter > compile(InputRange const &, flag_type = regex_constants::ECMAScript); static basic_regex< BidiIter > compile(char_type const *, flag_type = regex_constants::ECMAScript); static basic_regex< BidiIter > compile(char_type const *, std::size_t, flag_type); // public data members static regex_constants::syntax_option_type const ECMAScript; static regex_constants::syntax_option_type const icase; static regex_constants::syntax_option_type const nosubs; static regex_constants::syntax_option_type const optimize; static regex_constants::syntax_option_type const collate; static regex_constants::syntax_option_type const single_line; static regex_constants::syntax_option_type const not_dot_null; static regex_constants::syntax_option_type const not_dot_newline; static regex_constants::syntax_option_type const ignore_white_space; };
basic_regex
public member functionsbasic_regex();
Postconditions: |
regex_id() == 0 |
Postconditions: |
mark_count() == 0 |
basic_regex(basic_regex< BidiIter > const & that);
Parameters: |
|
||
Postconditions: |
regex_id() == that.regex_id() |
||
Postconditions: |
mark_count() == that.mark_count() |
basic_regex< BidiIter > & operator=(basic_regex< BidiIter > const & that);
Parameters: |
|
||
Postconditions: |
regex_id() == that.regex_id() |
||
Postconditions: |
mark_count() == that.mark_count() |
||
Returns: |
*this |
template<typename Expr> basic_regex(Expr const & expr);
Construct from a static regular expression.
Parameters: |
|
||
Requires: |
Expr is the type of a static regular expression. |
||
Postconditions: |
regex_id() != 0 |
||
Postconditions: |
mark_count() >= 0 |
template<typename Expr> basic_regex< BidiIter > & operator=(Expr const & expr);
Construct from a static regular expression.
Parameters: |
|
||
Requires: |
Expr is the type of a static regular expression. |
||
Postconditions: |
regex_id() != 0 |
||
Postconditions: |
mark_count() >= 0 |
||
Returns: |
*this |
||
Throws: |
std::bad_alloc on out of memory |
std::size_t mark_count() const;
Returns the count of capturing sub-expressions in this regular expression
regex_id_type regex_id() const;
Returns a token which uniquely identifies this regular expression.
void swap(basic_regex< BidiIter > & that);
Swaps the contents of this basic_regex object with another.
![]() |
Important |
---|---|
This is a shallow swap that does not do reference tracking. If you embed a basic_regex object by reference in another regular expression and then swap its contents with another basic_regex object, the change will not be visible to the enclosing regular expression. It is done this way to ensure that swap() cannot throw. |
Parameters: |
|
||
Throws: |
Will not throw. |
basic_regex
public static functionstemplate<typename InputIter> static basic_regex< BidiIter > compile(InputIter begin, InputIter end, flag_type flags = regex_constants::ECMAScript);
Factory method for building a regex object from a range of characters. Equivalent to regex_compiler< BidiIter >().compile(begin, end, flags);
Parameters: |
|
||||||
Requires: |
[begin,end) is a valid range. |
||||||
Requires: |
The range of characters specified by [begin,end) contains a valid string-based representation of a regular expression. |
||||||
Returns: |
A basic_regex object corresponding to the regular expression represented by the character range. |
||||||
Throws: |
regex_error when the range of characters has invalid regular expression syntax. |
template<typename InputRange> static basic_regex< BidiIter > compile(InputRange const & pat, flag_type flags = regex_constants::ECMAScript);
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
static basic_regex< BidiIter > compile(char_type const * begin, flag_type flags = regex_constants::ECMAScript);
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
static basic_regex< BidiIter > compile(char_type const * begin, std::size_t len, flag_type flags);
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.