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 移除

参阅

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

版本历史

  • (当前 | 先前 2017年6月16日 (五) 08:48Fruderica讨论 | 贡献. . (4,056字节) (-378). . (撤销)
  • 当前 | 先前 2013年7月2日 (二) 09:30P12bot讨论 | 贡献 . . (4,434字节) (-127). . (Use {{lc}}. Update links. Various fixes.) (撤销)
  • 当前 | 先前 2012年11月2日 (五) 12:33P12bot讨论 | 贡献 . . (4,561字节) (+265). . (r2.7.3) (机器人添加:de, en, es, fr, it, ja, pt, ru) (撤销)
  • 当前 | 先前 2012年10月27日 (六) 09:06P12讨论 | 贡献 . . (4,296字节) (0). . (1个修订: Translate from the English version) (撤销)
  • 当前 | 先前 2012年10月26日 (五) 06:00TranslationBot讨论 | 贡献. . (4,296字节) (-75). . (Translated from the English version using Google Translate) (撤销)
  • 当前 | 先前 2012年10月25日 (四) 15:32P12讨论 | 贡献 . . (4,371字节) (0). . (1个修订: Translate from the English version) (撤销)
  • 当前 | 先前) 2012年10月25日 (四) 12:00TranslationBot讨论 | 贡献. . (4,371字节) (+4,371). . (Translated from the English version using Google Translate)