basic_regex Class

自動換行規則運算式。

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
    };

參數

  • Elem
    要符合的項目型別。

  • RXtraits
    項目的特性類別。

備註

樣板類別描述物件,包含規則運算式。這個範本類別的物件可以傳遞至樣板函式regex_match Functionregex_search Function,以及regex_replace Function,連同合適的文字字串引數,搜尋符合規則運算式的文字。TR1 程式庫所提供的此樣板類別,與型別定義的兩個特製化regex Typedef為型別的項目char,以及wregex Typedef項目的型別wchar_t。

樣板引數RXtraits說明各種的樣板類別所支援的規則運算式語法的重要屬性。指定這些規則運算式特性的類別必須具有相同的外部介面的樣板類別物件regex_traits Class

有些函式採用了定義規則運算式的運算元序列。您可以指定這類運算元序列都算一個幾種方法:

ptr-null 結束的順序 (C 的字串,例如的Elem型別的char) 其起始地ptr (其中不得為空值的指標),終止的元素是值的地方value_type()而不是運算元的順序的一部份

ptrcount -一系列count項目,其起始地ptr (其中不得為空值的指標)

str-所指定的順序basic_string物件str

firstlast -一系列項目隔開的 iterator first和last,在範圍內[first, last)

right- basic_regex物件right

這些成員函式也採用的引數flags ,指定規則運算式,除了所描述的轉譯工作的不同選項RXtraits型別。

需求

標頭: <regex>

Namespace: 標準

請參閱

參考

<regex>

regex_match Function

regex_search Function

regex_replace Function

regex Typedef

wregex Typedef

regex_traits Class

其他資源

<regex> 成員