std::basic_regex::basic_regex

basic_regex();
(1) (C++11 起)
explicit basic_regex( const CharT* s,
                      flag_type f = std::regex_constants::ECMAScript );
(2) (C++11 起)
basic_regex( const CharT* s, std::size_t count,
             flag_type f = std::regex_constants::ECMAScript );
(3) (C++11 起)
basic_regex( const basic_regex& other );
(4) (C++11 起)
basic_regex( basic_regex&& other ) noexcept;
(5) (C++11 起)
template< class ST, class SA >

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

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

basic_regex( ForwardIt first, ForwardIt last,

             flag_type f = std::regex_constants::ECMAScript );
(7) (C++11 起)
basic_regex( std::initializer_list<CharT> init,
             flag_type f = std::regex_constants::ECMAScript );
(8) (C++11 起)

从按照标志 f 转译的字符序列构造新的正则表达式。

1) 默认构造函数。构造将不匹配内容的空正则表达式。
2) 从空终止字符串 s 构造正则表达式。
3)s 所指向的 count 个的字符序列构造正则表达式。
4) 复制构造函数。通过复制 other 构造正则表达式。
5) 移动构造函数。用移动语义构造拥有 other 内容的正则表达式。
6) 从 string str 构造正则表达式。
7) 范围构造函数。构造拥有范围 [first, last) 内容的正则表达式。
8) initializer_list 构造函数。构造拥有 initializer_list init 内容的正则表达式。

参数

s - 指向空终止字符串的指针
count - 用于初始化 regex 的字符序列长度
first, last - 用于初始化 regex 的字符序列范围
str - 用作源初始化 regex 的 basic_string
other - 用作源初始化 regex 的另一 regex
init - 用于初始化 regex 的 initializer_list
f - 用于指引转译字符序列为正则表达式的标志
类型要求
-
ForwardIt 必须满足 ForwardIterator 的要求。

异常

1) (无)
2-3) 若提供的正则表达式非法则为 std::regex_error
4) (无)
6-8) 若提供的正则表达式非法则为 std::regex_error

版本历史

  • (当前 | 先前 2017年9月29日 (五) 01:00Fruderica讨论 | 贡献. . (2,610字节) (-1,890). . (撤销)
  • 当前 | 先前 2013年7月2日 (二) 09:30P12bot讨论 | 贡献 . . (4,500字节) (-328). . (Use {{lc}}. Update links. Various fixes.) (撤销)
  • 当前 | 先前 2012年11月2日 (五) 12:48P12bot讨论 | 贡献 . . (4,828字节) (+329). . (r2.7.3) (机器人添加:de, en, es, fr, it, ja, pt, ru) (撤销)
  • 当前 | 先前 2012年10月27日 (六) 09:06P12讨论 | 贡献 . . (4,499字节) (0). . (1个修订: Translate from the English version) (撤销)
  • 当前 | 先前 2012年10月26日 (五) 06:00TranslationBot讨论 | 贡献. . (4,499字节) (-100). . (Translated from the English version using Google Translate) (撤销)
  • 当前 | 先前 2012年10月25日 (四) 15:32P12讨论 | 贡献 . . (4,599字节) (0). . (1个修订: Translate from the English version) (撤销)
  • 当前 | 先前) 2012年10月25日 (四) 12:00TranslationBot讨论 | 贡献. . (4,599字节) (+4,599). . (Translated from the English version using Google Translate)