命名空间
变体
操作

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

来自 cppreference.cn
< cpp‎ | regex‎ | basic regex
 
 
 
正则表达式库
(C++11)
算法
迭代器
异常
特性
常量
(C++11)
正则表达式语法
 
 
basic_regex& assign( const basic_regex& other );
(1) (since C++11)
basic_regex& assign( basic_regex&& other ) noexcept;
(2) (since C++11)
basic_regex& assign( const CharT* s,
                     flag_type f = std::regex_constants::ECMAScript );
(3) (since C++11)
basic_regex& assign( const CharT* ptr, std::size_t count,
                     flag_type f = std::regex_constants::ECMAScript );
(4) (since 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) (since C++11)
template< class InputIt >

basic_regex& assign( InputIt first, InputIt last,

                     flag_type f = std::regex_constants::ECMAScript );
(6) (since C++11)
basic_regex& assign( std::initializer_list<CharT> ilist,
                     flag_type f = std::regex_constants::ECMAScript );
(7) (since 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) 赋值字符串 str
6) 赋值范围 [firstlast) 中的字符。
7) 赋值初始化列表 ilist 中的字符。

内容

[edit] 参数

other - 要赋值的另一个正则表达式
s - 指向要赋值的字符序列的指针
str - 要赋值的字符串
first, last - 要赋值的字符范围
ilist - 包含要赋值字符的初始化列表
类型要求
-
InputIt 必须满足 LegacyInputIterator 的要求。

[edit] 返回值

*this

[edit] 异常

1) 可能抛出实现定义的异常。
3-7) 如果提供的正则表达式无效,则抛出 std::regex_error 异常。 在这种情况下,对象不会被修改。

[edit] 示例

[edit] 参见

赋值内容
(public member function) [编辑]