首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

regex

此标头是正则表达式图书馆。

命名空间std::regex_constants

类型

*。

在命名空间std::regex中定义[医]常数

句法[医]期权[医]类型%28C++11%29控制正则表达式行为的一般选项%28

匹配[医]旗子[医]类型%28C++11%29选项特定于匹配%28

误差[医]类型%28C++11%29描述不同类型的匹配错误%28

basic_regex (C++11)

regular expression object (class template)

sub_match (C++11)

identifies the sequence of characters matched by a sub-expression (class template)

match_results (C++11)

identifies one regular expression match, including all sub-expression matches (class template)

regex_iterator (C++11)

iterates through all regex matches within a character sequence (class template)

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)

regex_error (C++11)

reports errors generated by the regular expressions library (class)

regex_traits (C++11)

provides metainformation about a character type, required by the regex library (class template)

功能

算法

*。

雷吉[医]Match%28C++11%29尝试将正则表达式与整个字符序列%28函数模板%29匹配

雷吉[医]搜索%28C++11%29尝试将正则表达式与字符序列%28函数模板%29的任何部分匹配

雷吉[医]替换%28C++11%29用格式化替换文本%28函数模板%29替换正则表达式

非会员业务

STD::交换%28 std::basic[医]regex%29%28C++11%29专门开发std::交换算法%28函数模板%29

运算符==运算符%21=运算符<运算符<=运算符>>=比较两个子[医]匹配对象%28函数模板%29

运算符<<输出匹配字符子序列%28函数模板%29

运算符==运算符%21=按字典顺序比较两个匹配结果%28函数模板%29中的值

STD::交换%28 std::Match[医]结果29%28 C++11%29专门用于性病::交换%28%29算法%28功能模板%29

简介

二次

代码语言:javascript
复制
#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

二次

命名空间std::regex_constants

二次

代码语言:javascript
复制
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*/ ;
 
}

二次

std::regex_error

二次

代码语言:javascript
复制
class regex_error : public std::runtime_error {
public:
    explicit regex_error(regex_constants::error_type ecode);
    regex_constants::error_type code() const;
};

二次

std::regex_traits

二次

代码语言:javascript
复制
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;
};

二次

std::regex

二次

代码语言:javascript
复制
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&);
};

二次

std::sub_match

二次

代码语言:javascript
复制
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;
};

二次

std::match_results

二次

代码语言:javascript
复制
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);
 
};

二次

代码语言:txt
复制
 © cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券