##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# Standard library header <regex>

From cppreference.com
< cpp‎ | header

This header is part of the regular expressions library.

### [edit] Namespace std::regex_constants

##### Types
Defined in namespace `std::regex_constants`
syntax_option_type (C++11) | general options controlling regex behavior (typedef) [edit]
match_flag_type (C++11) | options specific to matching (typedef) [edit]
error_type (C++11) | describes different types of matching errors (typedef) [edit]

| This section is incomplete Reason: list all constants

### [edit] Classes

basic_regex (C++11) | regular expression object (class template) [edit]
sub_match (C++11) | identifies the sequence of characters matched by a sub-expression (class template) [edit]
match_results (C++11) | identifies one regular expression match, including all sub-expression matches (class template) [edit]
regex_iterator (C++11) | iterates through all regex matches within a character sequence (class template) [edit]
regex_token_iterator (C++11) | iterates through the specified sub-expressions within all regex matches in a given string or through unmatched substrings (class template) [edit]
regex_error (C++11) | reports errors generated by the regular expressions library (class) [edit]
regex_traits (C++11) | provides metainformation about a character type, required by the regex library (class template) [edit]

### [edit] Functions

##### Algorithm
regex_match (C++11) | attempts to match a regular expression to an entire character sequence (function template) [edit]
regex_search (C++11) | attempts to match a regular expression to any part of a character sequence (function template) [edit]
regex_replace (C++11) | replaces occurrences of a regular expression with formatted replacement text (function template) [edit]
##### Non-member operations
std::swap(std::basic_regex) (C++11) | specializes the std::swap algorithm (function template) [edit]
operator==operator!=operator<operator<=operator>operator>= | compares two `sub_match` objects (function) [edit]
operator<< | outputs the matched character subsequence (function template)
operator==operator!= | lexicographically compares the values in the two match result (function template) [edit]
std::swap(std::match_results) (C++11) | specializes the `std::swap()` algorithm (function template) [edit]

### [edit] Synopsis

    #include <initializer_list>

    namespace std {

        // regex constants:
        namespace regex_constants {
            enum error_type;
        } // namespace regex_constants

        // class regex_error:
        class regex_error;
        // class template regex_traits:
        template <class charT> struct regex_traits;
        // class template basic_regex:
        template <class charT, class traits = regex_traits<charT> > class basic_regex;

        typedef basic_regex<char> regex;
        typedef basic_regex<wchar_t> wregex;

        // basic_regex swap:
        template <class charT, class traits>
            void swap(basic_regex<charT, traits>& e1, basic_regex<charT, traits>& e2);

        // class template sub_match:
        template <class BidirectionalIterator> class sub_match;

        typedef sub_match<const char*>              csub_match;
        typedef sub_match<const wchar_t*>           wcsub_match;
        typedef sub_match<string::const_iterator>   ssub_match;
        typedef sub_match<wstring::const_iterator>  wssub_match;

        // sub_match non-member operators:
        template <class BiIter>
            bool operator==(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
        template <class BiIter>
            bool operator!=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
        template <class BiIter>
            bool operator<(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
        template <class BiIter>
            bool operator<=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
        template <class BiIter>
            bool operator>=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
        template <class BiIter>
            bool operator>(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);

        template <class BiIter, class ST, class SA>
            bool operator==(
                const basic_string<
                    typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
                const sub_match<BiIter>& rhs);
        template <class BiIter, class ST, class SA>
            bool operator!=(
                const basic_string<
                    typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
                const sub_match<BiIter>& rhs);
        template <class BiIter, class ST, class SA>
            bool operator<(
                const basic_string<
                    typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
                const sub_match<BiIter>& rhs);
        template <class BiIter, class ST, class SA>
            bool operator>(
                const basic_string<
                    typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
                const sub_match<BiIter>& rhs);
        template <class BiIter, class ST, class SA>
            bool operator>=(
                const basic_string<
                    typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
                const sub_match<BiIter>& rhs);
        template <class BiIter, class ST, class SA>
            bool operator<=(
                const basic_string<
                    typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
                const sub_match<BiIter>& rhs);

        template <class BiIter, class ST, class SA>
            bool operator==(
                const sub_match<BiIter>& lhs,
                const basic_string<
                    typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
        template <class BiIter, class ST, class SA>
            bool operator!=(
                const sub_match<BiIter>& lhs,
                const basic_string<
                    typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
        template <class BiIter, class ST, class SA>
            bool operator<(
                const sub_match<BiIter>& lhs,
                const basic_string<
                    typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
        template <class BiIter, class ST, class SA>
            bool operator>(
                const sub_match<BiIter>& lhs,
                const basic_string<
                    typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
        template <class BiIter, class ST, class SA>
            bool operator<=(
                const sub_match<BiIter>& lhs,
                const basic_string<
                    typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
        template <class BiIter, class ST, class SA>
            bool operator>=(
                const sub_match<BiIter>& lhs,
                const basic_string<
                    typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);

        template <class BiIter>
            bool operator==(typename iterator_traits<BiIter>::value_type const* lhs,
                const sub_match<BiIter>& rhs);
        template <class BiIter>
            bool operator!=(typename iterator_traits<BiIter>::value_type const* lhs,
                const sub_match<BiIter>& rhs);
        template <class BiIter>
            bool operator<(typename iterator_traits<BiIter>::value_type const* lhs,
                const sub_match<BiIter>& rhs);
        template <class BiIter>
            bool operator>(typename iterator_traits<BiIter>::value_type const* lhs,
                const sub_match<BiIter>& rhs);
        template <class BiIter>
            bool operator>=(typename iterator_traits<BiIter>::value_type const* lhs,
                const sub_match<BiIter>& rhs);
        template <class BiIter>
            bool operator<=(typename iterator_traits<BiIter>::value_type const* lhs,
                const sub_match<BiIter>& rhs);

        template <class BiIter>
            bool operator==(const sub_match<BiIter>& lhs,
                typename iterator_traits<BiIter>::value_type const* rhs);
        template <class BiIter>
            bool operator!=(const sub_match<BiIter>& lhs,
                typename iterator_traits<BiIter>::value_type const* rhs);
        template <class BiIter>
            bool operator<=(const sub_match<BiIter>& lhs,
                typename iterator_traits<BiIter>::value_type const* rhs);
        template <class BiIter>
            bool operator>=(const sub_match<BiIter>& lhs,
                typename iterator_traits<BiIter>::value_type const* rhs);
        template <class BiIter>
            bool operator<(const sub_match<BiIter>& lhs,
                typename iterator_traits<BiIter>::value_type const* rhs);
        template <class BiIter>
            bool operator>(const sub_match<BiIter>& lhs,
                typename iterator_traits<BiIter>::value_type const* rhs);

        template <class BiIter>
            bool operator==(typename iterator_traits<BiIter>::value_type const& lhs,
                const sub_match<BiIter>& rhs);
        template <class BiIter>
            bool operator!=(typename iterator_traits<BiIter>::value_type const& lhs,
                const sub_match<BiIter>& rhs);
        template <class BiIter>
            bool operator>=(typename iterator_traits<BiIter>::value_type const& lhs,
                const sub_match<BiIter>& rhs);
        template <class BiIter>
            bool operator<=(typename iterator_traits<BiIter>::value_type const& lhs,
                const sub_match<BiIter>& rhs);
        template <class BiIter>
            bool operator>(typename iterator_traits<BiIter>::value_type const& lhs,
                const sub_match<BiIter>& rhs);
        template <class BiIter>
            bool operator<(typename iterator_traits<BiIter>::value_type const& lhs,
                const sub_match<BiIter>& rhs);

        template <class BiIter>
            bool operator==(const sub_match<BiIter>& lhs,
                typename iterator_traits<BiIter>::value_type const& rhs);
        template <class BiIter>
            bool operator!=(const sub_match<BiIter>& lhs,
                typename iterator_traits<BiIter>::value_type const& rhs);
        template <class BiIter>
            bool operator>=(const sub_match<BiIter>& lhs,
                typename iterator_traits<BiIter>::value_type const& rhs);
        template <class BiIter>
            bool operator<=(const sub_match<BiIter>& lhs,
                typename iterator_traits<BiIter>::value_type const& rhs);
        template <class BiIter>
            bool operator<(const sub_match<BiIter>& lhs,
                typename iterator_traits<BiIter>::value_type const& rhs);
        template <class BiIter>
            bool operator>(const sub_match<BiIter>& lhs,
                typename iterator_traits<BiIter>::value_type const& rhs);

        template <class charT, class ST, class BiIter>
            basic_ostream<charT, ST>&
            operator<<(basic_ostream<charT, ST>& os, const sub_match<BiIter>& m);

        // class template match_results:
        template <class BidirectionalIterator,
                  class Allocator = allocator<sub_match<BidirectionalIterator> > >
            class match_results;

        typedef match_results<const char*>              cmatch;
        typedef match_results<const wchar_t*>           wcmatch;
        typedef match_results<string::const_iterator>   smatch;
        typedef match_results<wstring::const_iterator>  wsmatch;

        // match_results comparisons
        template <class BidirectionalIterator, class Allocator>
            bool operator== (const match_results<BidirectionalIterator, Allocator>& m1,
                             const match_results<BidirectionalIterator, Allocator>& m2);
        template <class BidirectionalIterator, class Allocator>
            bool operator!= (const match_results<BidirectionalIterator, Allocator>& m1,
                             const match_results<BidirectionalIterator, Allocator>& m2);

        //  match_results swap:
        template <class BidirectionalIterator, class Allocator>
            void swap(match_results<BidirectionalIterator, Allocator>& m1,
                      match_results<BidirectionalIterator, Allocator>& m2);

        //  function template regex_match:
        template <class BidirectionalIterator, class Allocator,
                  class charT, class traits>
            bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
                             match_results<BidirectionalIterator, Allocator>& m,
                             const basic_regex<charT, traits>& e,
                             regex_constants::match_flag_type flags =
                                regex_constants::match_default);
        template <class BidirectionalIterator, class charT, class traits>
            bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
                             const basic_regex<charT, traits>& e,
                             regex_constants::match_flag_type flags =
                                regex_constants::match_default);
        template <class charT, class Allocator, class traits>
            bool regex_match(const charT* str, match_results<const charT*, Allocator>& m,
                             const basic_regex<charT, traits>& e,
                             regex_constants::match_flag_type flags =
                                regex_constants::match_default);
        template <class ST, class SA, class Allocator, class charT, class traits>
            bool regex_match(const basic_string<charT, ST, SA>& s,
                match_results<
                    typename basic_string<charT, ST, SA>::const_iterator,
                    Allocator>& m,
                const basic_regex<charT, traits>& e,
                regex_constants::match_flag_type flags =
                    regex_constants::match_default);
        template <class charT, class traits>
            bool regex_match(const charT* str,
                const basic_regex<charT, traits>& e,
                regex_constants::match_flag_type flags =
                    regex_constants::match_default);
        template <class ST, class SA, class charT, class traits>
            bool regex_match(const basic_string<charT, ST, SA>& s,
                const basic_regex<charT, traits>& e,
                regex_constants::match_flag_type flags =
                    regex_constants::match_default);

        // function template regex_search:
        template <class BidirectionalIterator, class Allocator,
                  class charT, class traits>
            bool regex_search(BidirectionalIterator first, BidirectionalIterator last,
                match_results<BidirectionalIterator, Allocator>& m,
                const basic_regex<charT, traits>& e,
                regex_constants::match_flag_type flags =
                    regex_constants::match_default);
        template <class BidirectionalIterator, class charT, class traits>
            bool regex_search(BidirectionalIterator first, BidirectionalIterator last,
                const basic_regex<charT, traits>& e,
                regex_constants::match_flag_type flags =
                    regex_constants::match_default);
        template <class charT, class Allocator, class traits>
            bool regex_search(const charT* str,
                match_results<const charT*, Allocator>& m,
                const basic_regex<charT, traits>& e,
                regex_constants::match_flag_type flags =
                    regex_constants::match_default);
        template <class charT, class traits>
            bool regex_search(const charT* str,
                const basic_regex<charT, traits>& e,
                    regex_constants::match_flag_type flags =
                        regex_constants::match_default);
        template <class ST, class SA, class charT, class traits>
            bool regex_search(const basic_string<charT, ST, SA>& s,
                const basic_regex<charT, traits>& e,
                regex_constants::match_flag_type flags =
                    regex_constants::match_default);
        template <class ST, class SA, class Allocator, class charT, class traits>
            bool regex_search(const basic_string<charT, ST, SA>& s,
                match_results<
                    typename basic_string<charT, ST, SA>::const_iterator,
                    Allocator>& m,
                const basic_regex<charT, traits>& e,
                regex_constants::match_flag_type flags =
                    regex_constants::match_default);

        //  function template regex_replace:
        template <class OutputIterator, class BidirectionalIterator,
                  class traits, class charT, class ST, class SA>
            OutputIterator
            regex_replace(  OutputIterator out,
                            BidirectionalIterator first,
                            BidirectionalIterator last,
                            const basic_regex<charT, traits>& e,
                            const basic_string<charT, ST, SA>& fmt,
                            regex_constants::match_flag_type flags =
                                regex_constants::match_default);
        template <class OutputIterator, class BidirectionalIterator,
                  class traits, class charT>
            OutputIterator
            regex_replace(  OutputIterator out,
                            BidirectionalIterator first,
                            BidirectionalIterator last,
                            const basic_regex<charT, traits>& e,
                            const charT* fmt,
                            regex_constants::match_flag_type flags =
                                regex_constants::match_default);
        template <class traits, class charT, class ST, class SA,
                  class FST, class FSA>
            basic_string<charT, ST, SA>
            regex_replace(  const basic_string<charT, ST, SA>& s,
                            const basic_regex<charT, traits>& e,
                            const basic_string<charT, FST, FSA>& fmt,
                            regex_constants::match_flag_type flags =
                                regex_constants::match_default);
        template <class traits, class charT, class ST, class SA>
            basic_string<charT, ST, SA>
            regex_replace(  const basic_string<charT, ST, SA>& s,
                            const basic_regex<charT, traits>& e,
                            const charT* fmt,
                            regex_constants::match_flag_type flags =
                                regex_constants::match_default);
        template <class traits, class charT, class ST, class SA>
            basic_string<charT>
            regex_replace(  const charT* s,
                            const basic_regex<charT, traits>& e,
                            const basic_string<charT, ST, SA>& fmt,
                            regex_constants::match_flag_type flags =
                                regex_constants::match_default);
        template <class traits, class charT>
            basic_string<charT>
            regex_replace(  const charT* s,
                            const basic_regex<charT, traits>& e,
                            const charT* fmt,
                            regex_constants::match_flag_type flags =
                                regex_constants::match_default);

        // class template regex_iterator:
        template <class BidirectionalIterator,
                  class charT = typename iterator_traits<
                        BidirectionalIterator>::value_type,
                  class traits = regex_traits<charT> >
            class regex_iterator;

        typedef regex_iterator<const char*>             cregex_iterator;
        typedef regex_iterator<const wchar_t*>          wcregex_iterator;
        typedef regex_iterator<string::const_iterator>  sregex_iterator;
        typedef regex_iterator<wstring::const_iterator> wsregex_iterator;

        // class template regex_token_iterator:
        template <class BidirectionalIterator,
                  class charT = typename iterator_traits<
                    BidirectionalIterator>::value_type,
                  class traits = regex_traits<charT> >
            class regex_token_iterator;

        typedef regex_token_iterator<const char*>               cregex_token_iterator;
        typedef regex_token_iterator<const wchar_t*>            wcregex_token_iterator;
        typedef regex_token_iterator<string::const_iterator>    scregex_token_iterator;
        typedef regex_token_iterator<wstring::const_iterator>   wscregex_token_iterator;

    } // namespace std

#### [edit] Namespace std::regex_constants

    namespace regex_constants {
        typedef /*T1*/ syntax_option_type;
        static constexpr syntax_option_type icase = /*unspecified*/ ;
        static constexpr syntax_option_type nosubs = /*unspecified*/ ;
        static constexpr syntax_option_type optimize = /*unspecified*/ ;
        static constexpr syntax_option_type collate = /*unspecified*/ ;
        static constexpr syntax_option_type ECMAScript = /*unspecified*/ ;
        static constexpr syntax_option_type basic = /*unspecified*/ ;
        static constexpr syntax_option_type extended = /*unspecified*/ ;
        static constexpr syntax_option_type awk = /*unspecified*/ ;
        static constexpr syntax_option_type grep = /*unspecified*/ ;
        static constexpr syntax_option_type egrep = /*unspecified*/ ;

        typedef /*T2*/ match_flag_type;
        static constexpr match_flag_type match_default = 0;
        static constexpr match_flag_type match_not_bol = /*unspecified*/ ;
        static constexpr match_flag_type match_not_eol = /*unspecified*/ ;
        static constexpr match_flag_type match_not_bow = /*unspecified*/ ;
        static constexpr match_flag_type match_not_eow = /*unspecified*/ ;
        static constexpr match_flag_type match_any = /*unspecified*/ ;
        static constexpr match_flag_type match_not_null = /*unspecified*/ ;
        static constexpr match_flag_type match_continuous = /*unspecified*/ ;
        static constexpr match_flag_type match_prev_avail = /*unspecified*/ ;
        static constexpr match_flag_type format_default = 0;
        static constexpr match_flag_type format_sed = /*unspecified*/ ;
        static constexpr match_flag_type format_no_copy = /*unspecified*/ ;
        static constexpr match_flag_type format_first_only = /*unspecified*/ ;

        typedef /*T3*/ error_type;
        static constexpr error_type error_collate = /*unspecified*/ ;
        static constexpr error_type error_ctype = /*unspecified*/ ;
        static constexpr error_type error_escape = /*unspecified*/ ;
        static constexpr error_type error_backref = /*unspecified*/ ;
        static constexpr error_type error_brack = /*unspecified*/ ;
        static constexpr error_type error_paren = /*unspecified*/ ;
        static constexpr error_type error_brace = /*unspecified*/ ;
        static constexpr error_type error_badbrace = /*unspecified*/ ;
        static constexpr error_type error_range = /*unspecified*/ ;
        static constexpr error_type error_space = /*unspecified*/ ;
        static constexpr error_type error_badrepeat = /*unspecified*/ ;
        static constexpr error_type error_complexity = /*unspecified*/ ;
        static constexpr error_type error_stack = /*unspecified*/ ;

    }

#### [edit] Class std::regex_error

    class regex_error : public std::runtime_error {
    public:
        explicit regex_error(regex_constants::error_type ecode);
        regex_constants::error_type code() const;
    };

#### [edit] Class std::regex_traits

    template <class charT>
    struct regex_traits {
    public:
        typedef charT                           char_type;
        typedef std::basic_string<char_type>    string_type;
        typedef std::locale                     locale_type;
        typedef /*bitmask_type*/                char_class_type;

        regex_traits();
        static std::size_t length(const char_type* p);
        charT translate(charT c) const;
        charT translate_nocase(charT c) const;
        template <class ForwardIterator>
            string_type transform(ForwardIterator first, ForwardIterator last) const;
        template <class ForwardIterator>
            string_type transform_primary(
                ForwardIterator first, ForwardIterator last) const;
        template <class ForwardIterator>
            string_type lookup_collatename(
                ForwardIterator first, ForwardIterator last) const;
        template <class ForwardIterator>
            char_class_type lookup_classname(
                ForwardIterator first, ForwardIterator last, bool icase = false) const;
        bool isctype(charT c, char_class_type f) const;
        int value(charT ch, int radix) const;
        locale_type imbue(locale_type l);
        locale_type getloc()const;
    };

#### [edit] Class std::regex

    template <class charT,
        class traits = regex_traits<charT> >
    class basic_regex {
    public:
        // types:
        typedef          charT                                  value_type;
        typedef          traits                                 traits_type;
        typedef typename traits::string_type                    string_type;
        typedef          regex_constants::syntax_option_type    flag_type;
        typedef typename traits::locale_type                    locale_type;

        //  constants:
        static constexpr regex_constants::syntax_option_type
            icase = regex_constants::icase;
        static constexpr regex_constants::syntax_option_type
            nosubs = regex_constants::nosubs;
        static constexpr regex_constants::syntax_option_type
            optimize = regex_constants::optimize;
        static constexpr regex_constants::syntax_option_type
            collate = regex_constants::collate;
        static constexpr regex_constants::syntax_option_type
            ECMAScript = regex_constants::ECMAScript;
        static constexpr regex_constants::syntax_option_type
            basic = regex_constants::basic;
        static constexpr regex_constants::syntax_option_type
            extended = regex_constants::extended;
        static constexpr regex_constants::syntax_option_type
            awk = regex_constants::awk;
        static constexpr regex_constants::syntax_option_type
            grep = regex_constants::grep;
        static constexpr regex_constants::syntax_option_type
            egrep = regex_constants::egrep;

        //construct/copy/destroy:
        basic_regex();
        explicit basic_regex(const charT* p,
            flag_type f = regex_constants::ECMAScript);
        basic_regex(const charT* p, size_t len, flag_type f = regex_constants::ECMAScript);
        basic_regex(const basic_regex&);
        basic_regex(basic_regex&&) noexcept;
        template <class ST, class SA>
            explicit basic_regex(const basic_string<charT, ST, SA>& p,
                flag_type f = regex_constants::ECMAScript);
        template <class ForwardIterator>
            basic_regex(ForwardIterator first, ForwardIterator last,
                flag_type f = regex_constants::ECMAScript);
        basic_regex(initializer_list<charT>,
            flag_type = regex_constants::ECMAScript);

        ~basic_regex();
        basic_regex& operator=(const basic_regex&);
        basic_regex& operator=(basic_regex&&) noexcept;
        basic_regex& operator=(const charT* ptr);
        basic_regex& operator=(initializer_list<charT> il);
        template <class ST, class SA>
            basic_regex& operator=(const basic_string<charT, ST, SA>& p);

        //  assign:
        basic_regex& assign(const basic_regex& that);
        basic_regex& assign(basic_regex&& that) noexcept;
        basic_regex& assign(const charT* ptr,
            flag_type f = regex_constants::ECMAScript);
        basic_regex& assign(const charT* p, size_t len, flag_type f);
        template <class string_traits, class A>
            basic_regex& assign(const basic_string<charT, string_traits, A>& s,
                flag_type f = regex_constants::ECMAScript);
        template <class InputIterator>
            basic_regex& assign(InputIterator first, InputIterator last,
                flag_type f = regex_constants::ECMAScript);
        basic_regex& assign(initializer_list<charT>,
            flag_type = regex_constants::ECMAScript);

        // const operations:
        unsigned mark_count() const;
        flag_type flags() const;

        // locale:
        locale_type imbue(locale_type loc);
        locale_type getloc() const;

        // swap:
        void swap(basic_regex&);
    };

#### [edit] Class std::sub_match

    template <class BidirectionalIterator>
    class sub_match : public std::pair<BidirectionalIterator, BidirectionalIterator> {
    public:
        typedef typename iterator_traits<BidirectionalIterator>::
            value_type                                              value_type;
        typedef typename iterator_traits<BidirectionalIterator>::
        difference_type                                             difference_type;
        typedef BidirectionalIterator                               iterator;
        typedef basic_string<value_type>                            string_type;

        bool matched;

        constexpr sub_match();
        difference_type length() const;
        operator string_type() const;
        string_type str() const;

        int compare(const sub_match& s) const;
        int compare(const string_type& s) const;
        int compare(const value_type* s) const;
    };

#### [edit] Class std::match_results

    template <class BidirectionalIterator,
                class Allocator = allocator<sub_match<BidirectionalIterator> >
    class match_results {
    public:
        typedef sub_match<BidirectionalIterator>                    value_type;
        typedef const value_type&                                   const_reference;
        typedef const_reference                                     reference;
        typedef /*implementation-defined*/                          const_iterator;
        typedef const_iterator                                      iterator;
        typedef typename
            iterator_traits<BidirectionalIterator>::difference_type difference_type;
        typedef typename allocator_traits<Allocator>::size_type     size_type;
        typedef Allocator                                           allocator_type;
        typedef typename
            iterator_traits<BidirectionalIterator>::value_type      char_type;
        typedef basic_string<char_type>                             string_type;

        // construct/copy/destroy:
        explicit match_results(const Allocator& a = Allocator());
        match_results(const match_results& m);
        match_results(match_results&& m) noexcept;
        match_results& operator=(const match_results& m);
        match_results& operator=(match_results&& m);
        ~match_results();

        // state:
        bool ready() const;

        // size:
        size_type size() const;
        size_type max_size() const;
        bool empty() const;

        // element access:
        difference_type length(size_type sub = 0) const;
        difference_type position(size_type sub = 0) const;
        string_type str(size_type sub = 0) const;
        const_reference operator[](size_type n) const;

        const_reference prefix() const;
        const_reference suffix() const;
        const_iterator  begin() const;
        const_iterator  end() const;
        const_iterator  cbegin() const;
        const_iterator  cend() const;

        //  format:
        template <class OutputIter>
            OutputIter
            format(OutputIter out,
                const char_type* fmt_first, const char_type* fmt_last,
                regex_constants::match_flag_type flags =
                regex_constants::format_default) const;
        template <class OutputIter, class ST, class SA>
            OutputIter
            format(OutputIter out,
                const basic_string<char_type, ST, SA>& fmt,
                regex_constants::match_flag_type flags =
                regex_constants::format_default) const;
        template <class ST, class SA>
            basic_string<char_type, ST, SA>
            format(const basic_string<char_type, ST, SA>& fmt,
                regex_constants::match_flag_type flags =
                regex_constants::format_default) const;
        string_type
            format(const char_type* fmt,
                regex_constants::match_flag_type flags =
                regex_constants::format_default) const;

        // allocator:
        allocator_type get_allocator() const;

        // swap:
        void swap(match_results& that);

    };

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/header/regex&oldid=65813"
Category:

- Todo with reason