Namespaces
Variants

std::regex_constants:: match_flag_type

From cppreference.net
定义于头文件 <regex>
using match_flag_type = /* 由实现定义 */ ;
(1) (C++11 起)
constexpr match_flag_type match_default = { } ;

constexpr match_flag_type match_not_bol = /* 未指定 */ ;
constexpr match_flag_type match_not_eol = /* 未指定 */ ;
constexpr match_flag_type match_not_bow = /* 未指定 */ ;
constexpr match_flag_type match_not_eow = /* 未指定 */ ;
constexpr match_flag_type match_any = /* 未指定 */ ;
constexpr match_flag_type match_not_null = /* 未指定 */ ;
constexpr match_flag_type match_continuous = /* 未指定 */ ;
constexpr match_flag_type match_prev_avail = /* 未指定 */ ;
constexpr match_flag_type format_default = { } ;
constexpr match_flag_type format_sed = /* 未指定 */ ;
constexpr match_flag_type format_no_copy = /* 未指定 */ ;

constexpr match_flag_type format_first_only = /* 未指定 */ ;
(2) (C++11 起)
(C++17 起为内联)
1) match_flag_type 是一个 BitmaskType ,用于指定额外的正则表达式匹配选项。

常量

注意: [ first , last ) 表示被匹配的字符序列。

名称 说明
match_not_bol [ first , last ) 中的首个字符视为 在行首
(即 ^ 不会匹配 [ first , first ) )。
match_not_eol [ first , last ) 中的末个字符视为 在行尾
(即 $ 不会匹配 [ last , last ) )。
match_not_bow \b 不会匹配 [ first , first )
match_not_eow \b 不会匹配 [ last , last )
match_any 若存在多个匹配可能,则任意匹配均为可接受结果。
match_not_null 不匹配空序列。
match_continuous 仅匹配始于 first 的子序列。
match_prev_avail -- first 是有效的迭代器位置。
设置时,将忽略 match_not_bol match_not_bow
format_default std::regex_replace 中使用 ECMAScript 规则构建字符串( 语法文档 )。
format_sed std::regex_replace 中使用 POSIX sed 工具规则( 语法文档 )。
format_no_copy std::regex_replace 中不将未匹配字符串复制到输出。
format_first_only std::regex_replace 中仅替换首个匹配项。

match_default format_default 外,所有常量均为位掩码元素。 match_default format_default 常量是空位掩码。

缺陷报告

以下行为变更缺陷报告被追溯应用于先前发布的C++标准。

缺陷报告 适用范围 发布时的行为 正确行为
LWG 2053 C++11 1. 常量被声明为 static
2. match_default format_default 0 初始化
1. 移除 static 说明符
2. 从 { } 初始化

参见

尝试将正则表达式与整个字符序列进行匹配
(函数模板)
控制正则表达式行为的通用选项
(类型定义)
(C++11)
描述不同类型的匹配错误
(类型定义)