C++ 参考手册

位置:首页 > C++ 参考手册 >正则表达式库 > std::regex_constants::match_flag_type

定义于头文件 <regex>
typedef /*unspecified*/ match_flag_type;
(C++11 起)
constexpr match_flag_type match_default = 0;

constexpr match_flag_type match_not_bol = /*unspecified*/;
constexpr match_flag_type match_not_eol = /*unspecified*/;
constexpr match_flag_type match_not_bow = /*unspecified*/;
constexpr match_flag_type match_not_eow = /*unspecified*/;
constexpr match_flag_type match_any = /*unspecified*/;
constexpr match_flag_type match_not_null = /*unspecified*/;
constexpr match_flag_type match_continuous = /*unspecified*/;
constexpr match_flag_type match_prev_avail = /*unspecified*/;
constexpr match_flag_type format_default = 0;
constexpr match_flag_type format_sed = /*unspecified*/;
constexpr match_flag_type format_no_copy = /*unspecified*/;

constexpr match_flag_type format_first_only = /*unspecified*/;
(C++11 起)
(C++17 前)
inline constexpr match_flag_type match_default = 0;

inline constexpr match_flag_type match_not_bol = /*unspecified*/;
inline constexpr match_flag_type match_not_eol = /*unspecified*/;
inline constexpr match_flag_type match_not_bow = /*unspecified*/;
inline constexpr match_flag_type match_not_eow = /*unspecified*/;
inline constexpr match_flag_type match_any = /*unspecified*/;
inline constexpr match_flag_type match_not_null = /*unspecified*/;
inline constexpr match_flag_type match_continuous = /*unspecified*/;
inline constexpr match_flag_type match_prev_avail = /*unspecified*/;
inline constexpr match_flag_type format_default = 0;
inline constexpr match_flag_type format_sed = /*unspecified*/;
inline constexpr match_flag_type format_no_copy = /*unspecified*/;

inline constexpr match_flag_type format_first_only = /*unspecified*/;
(C++17 起)

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_bolmatch_not_bow 被忽略
format_default 使用 ECMAScript 规则于 std::regex_replace 构造字符串(语法文档
format_sed std::regex_replace 使用 POSIX sed 工具规则。(语法文档
format_no_copy 不复制不匹配的字符串到 std::regex_replace 中的输出
format_first_only 仅替换 std::regex_replace 中的首个匹配

match_defaultformat_default 以外的所有常量都是位掩码元素。 match_defaultformat_default 常量是空位掩码

注意

C++11 中,这些常量曾被指定带有冗余的关键词 static ,它为 C++14 通过 LWG 问题 2053 移除

参阅

尝试匹配一个正则表达式到整个字符序列
(函数模板)
控制正则表达式行为的通用选项
(typedef)
描述不同类型的匹配错误
(typedef)