basic_regex Class
Wraps a regular expression.
template<class Elem,
class RXtraits = regex_traits<Elem>,
class basic_regex {
public:
basic_regex();
explicit basic_regex(const Elem *ptr,
flag_type flags = ECMAScript);
basic_regex(const Elem *ptr, size_type len,
flag_type flags = ECMAScript);
basic_regex(const basic_regex& right);
template<class STtraits, class STalloc>
explicit basic_regex(const basic_string<Elem, STtraits, STalloc>& str,
flag_type flags = ECMAScript);
template<class InIt>
explicit basic_regex(InIt first, InIt last,
flag_type flags = ECMAScript);
basic_regex& operator=(const basic_regex& right);
basic_regex& operator=(const Elem *ptr);
template<class STtraits, class STalloc>
basic_regex& operator=(const basic_string<Elem, STtraits, STalloc>& str);
basic_regex& assign(const basic_regex& right);
basic_regex& assign(const Elem *ptr,
flag_type flags = ECMAScript);
basic_regex& assign(const Elem *ptr, size_type len,
flag_type flags = ECMAScript);
template<class STtraits, class STalloc>
basic_regex& assign(const basic_string<Elem, STtraits, STalloc>& str,
flag_type flags = ECMAScript);
template<class InIt>
basic_regex& assign(InIt first, InIt last,
flag_type flags = ECMAScript);
locale_type imbue(locale_type loc);
locale_type getloc() const;
void swap(basic_regex& other) throw();
unsigned mark_count() const;
flag_type flags() const;
typedef Elem value_type;
typedef regex_constants::syntax_option_type flag_type;
typedef typename RXtraits::locale_type locale_type;
static const flag_type icase = regex_constants::icase;
static const flag_type nosubs = regex_constants::nosubs;
static const flag_type optimize = regex_constants::optimize;
static const flag_type collate = regex_constants::collate;
static const flag_type ECMAScript = regex_constants::ECMAScript;
static const flag_type basic = regex_constants::basic;
static const flag_type extended = regex_constants::extended;
static const flag_type awk = regex_constants::awk;
static const flag_type grep = regex_constants::grep;
static const flag_type egrep = regex_constants::egrep;
private:
RXtraits traits; // exposition only
};
Parameters
Elem
The type of elements to match.RXtraits
Traits class for elements.
Remarks
The template class describes an object that holds a regular expression. Objects of this template class can be passed to the template functions regex_match Function, regex_search Function, and regex_replace Function, along with suitable text string arguments, to search for text that matches the regular expression. There are two specializations of this template class, with the type definitions regex Typedef for elements of type char, and wregex Typedef for elements of type wchar_t.
The template argument RXtraits describes various important properties of the syntax of the regular expressions that the template class supports. A class that specifies these regular expression traits must have the same external interface as an object of template class regex_traits Class.
Some functions take an operand sequence that defines a regular expression. You can specify such an operand sequence several ways:
ptr -- a null-terminated sequence (such as a C string, for Elem of type char) beginning at ptr (which must not be a null pointer), where the terminating element is the value value_type() and is not part of the operand sequence
ptr, count -- a sequence of count elements beginning at ptr (which must not be a null pointer)
str -- the sequence specified by the basic_string object str
first, last -- a sequence of elements delimited by the iterators first and last, in the range [first, last)
right -- the basic_regex object right
These member functions also take an argument flags that specifies various options for the interpretation of the regular expression in addition to those described by the RXtraits type.
Requirements
Header: <regex>
Namespace: std