名稱空間
變體
操作

std::basic_regex<CharT,Traits>::assign

來自 cppreference.com
< cpp‎ | regex‎ | basic_regex
 
 
 
正則表示式庫
(C++11)
演算法
迭代器
異常
特性
常量
(C++11)
正則表示式語法
 
 
basic_regex& assign( const basic_regex& other );
(1) (C++11 起)
basic_regex& assign( basic_regex&& other ) noexcept;
(2) (C++11 起)
basic_regex& assign( const CharT* s,
                     flag_type f = std::regex_constants::ECMAScript );
(3) (C++11 起)
basic_regex& assign( const CharT* ptr, std::size_t count,
                     flag_type f = std::regex_constants::ECMAScript );
(4) (C++11 起)
template< class ST, class SA >

basic_regex& assign( const std::basic_string<CharT,ST,SA>& str,

                     flag_type f = std::regex_constants::ECMAScript );
(5) (C++11 起)
template< class InputIt >

basic_regex& assign( InputIt first, InputIt last,

                     flag_type f = std::regex_constants::ECMAScript );
(6) (C++11 起)
basic_regex& assign( std::initializer_list<CharT> ilist,
                     flag_type f = std::regex_constants::ECMAScript );
(7) (C++11 起)

將內容賦值給正則表示式。

1) 賦值 other 的內容。flags()mark_count() 在呼叫後與 other.flags()other.mark_count() 的值相等。
2) 使用移動語義賦值 other 的內容。flags()mark_count() 在賦值前與 other.flags()other.mark_count() 的值相等。呼叫後,other 處於一個有效但未指定的狀態。
3-7) 將字元序列賦值給正則表示式。語法標誌設定為 fmark_count() 返回呼叫後結果子表示式中標記的子表示式數量。
3) 賦值由 s 指向的以 null 結尾的字串。
4) 賦值由 s 指向的 count 個字元的序列。
5) 賦值字串 str
6) 賦值範圍 [firstlast) 中的字元。
7) 賦值初始化列表 ilist 中的字元。

目錄

[編輯] 引數

其他 - 要賦值的另一個正則表示式
s - 指向要賦值的字元序列的指標
str - 要賦值的字串
first, last - 要賦值的字元範圍
ilist - 包含要賦值字元的初始化列表
型別要求
-
InputIt 必須滿足 LegacyInputIterator 的要求。

[編輯] 返回值

*this

[編輯] 異常

1) 可能會丟擲實現定義的異常。
3-7) 如果提供的正則表示式無效,則丟擲 std::regex_error。在這種情況下,物件不會被修改。

[編輯] 示例

[編輯] 參閱

賦值內容
(public member function) [編輯]