Namespaces
Variants

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

From cppreference.net
Regular expressions library
Classes
(C++11)
Algorithms
Iterators
Exceptions
Traits
Constants
(C++11)
Regex Grammar
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) 将字符序列分配给正则表达式。语法标志设置为 f mark_count() 返回调用后结果子表达式中标记子表达式的数量。
3) s 所指向的以空字符结尾的字符串进行赋值。
4) 分配由 s 指向的 count 个字符组成的序列。
5) 将字符串 str 赋值。
6) 将范围 [ first , last ) 内的字符进行赋值。
7) 将初始化列表 ilist 中的字符进行赋值。

目录

参数

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

返回值

* this

异常

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

示例

参见

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