C++ 参考手册

位置:首页 > C++ 参考手册 >正则表达式库 >std::basic_regex > std::basic_regex<CharT,Traits>::assign

basic_regex& assign( const basic_regex& other );
(1) (C++11 起)
basic_regex& assign( basic_regex&& that ) 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, 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) 赋值字符序列给正则表达式。设置语法标志为 f 。调用后 mark_count() 产生的子表达式中的有标记子表达式数。
3) 赋值 s 所指向的空终止字符串。
4) 赋值 s 所指向的 count 个字符序列。
5) 赋值 string str
6) 赋值范围 [first, last) 中的字符。
7) 赋值 initializer_list ilist 中的字符。

参数

other - 要赋值的另一正则表达式
s - 指向要赋值的字符序列的指针
str - 要赋值的 string
first, last - 要赋值的字符范围
ilist - 含要赋值的字符的 initializer_list
类型要求
-
InputIt 必须满足遗留输入迭代器 (LegacyInputIterator) 的要求。

返回值

*this

异常

1) (无)
3-7) 若提供的正则表达式非法则为 std::regex_error 。该情况下不修改对象。

示例

本节未完成
原因:暂无示例

参阅

赋值内容
(公开成员函数)