名稱空間
變體
操作

std::regex_constants::match_flag_type

來自 cppreference.com
< cpp‎ | regex
在標頭檔案 <regex> 中定義
using match_flag_type = /* implementation-defined */;
(1) (C++11 起)
constexpr match_flag_type match_default =     {};

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 =    {};
constexpr match_flag_type format_sed =        /* unspecified */;
constexpr match_flag_type format_no_copy =    /* unspecified */;

constexpr match_flag_type format_first_only = /* unspecified */;
(2) (C++11 起)
(C++17 起為 inline)
1) match_flag_type 是一種 BitmaskType,它指定了額外的正則表示式匹配選項。

[edit] 常量

注意:[firstlast) 指的是正在匹配的字元序列。

名稱 解釋
match_not_bol [firstlast) 中的第一個字元將被視為不在行首
(即 ^ 不會匹配 [firstfirst))。
match_not_eol [firstlast) 中的最後一個字元將被視為不在行尾
(即 $ 不會匹配 [lastlast))。
match_not_bow \b 不會匹配 [firstfirst)
match_not_eow \b 不會匹配 [lastlast)
match_any 如果可能存在多個匹配項,則任何一個匹配項都是可接受的結果。
match_not_null 不匹配空序列。
match_continuous 只匹配始於 first 的子序列。
match_prev_avail --first 是一個有效的迭代器位置。
設定時,會導致 match_not_bolmatch_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_defaultformat_default 外,所有常量都是位掩碼元素。match_defaultformat_default 常量是空位掩碼。

[edit] 缺陷報告

下列更改行為的缺陷報告追溯地應用於以前出版的 C++ 標準。

缺陷報告 應用於 釋出時的行為 正確的行為
LWG 2053 C++11 1. 常量被宣告為 static
2. match_defaultformat_default0 初始化
1. 移除了 static 指定符
2. 從 {} 初始化

[edit] 參閱

嘗試將正則表示式與整個字元序列匹配
(函式模板) [編輯]
控制正則表示式行為的通用選項
(typedef) [編輯]
描述不同型別的匹配錯誤
(typedef) [編輯]