std::basic_regex constants

從 cppreference.com
< cpp‎ | regex‎ | basic regex
在2012年10月25日 (四) 13:00由TranslationBot對話 | 貢獻所做的修訂版本

(差異) ←上一修訂 | 最新修訂 (差異) | 下一修訂→ (差異)

 
 
 
正則表達式庫
(C++11)
算法
迭代器
異常
特徵
常量
(C++11)
正則表達式文法
 
 
<tr class="t-dsc-header"> <td>
在標頭 <regex> 定義
</td>

<td></td> <td></td> </tr> <tr class="t-dcl ">

<td class="t-dcl-nopad">
static constexpr std::regex_constants::syntax_option_type icase =

    std::regex_constants::icase;
static constexpr std::regex_constants::syntax_option_type nosubs =
    std::regex_constants::nosubs;
static constexpr std::regex_constants::syntax_option_type optimize =
    std::regex_constants::optimize;
static constexpr std::regex_constants::syntax_option_type collate =
    std::regex_constants::collate;
static constexpr std::regex_constants::syntax_option_type ECMAScript =
    std::regex_constants::ECMAScript;
static constexpr std::regex_constants::syntax_option_type basic =
    std::regex_constants::basic;
static constexpr std::regex_constants::syntax_option_type extended =
    std::regex_constants::extended;
static constexpr std::regex_constants::syntax_option_type awk =
    std::regex_constants::awk;
static constexpr std::regex_constants::syntax_option_type grep =
    std::regex_constants::grep;
static constexpr std::regex_constants::syntax_option_type egrep =

    std::regex_constants::egrep;
</td>

<td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr>

std::basic_regex定義幾個常量管理一般的正則表達式匹配的語法.
原文:
std::basic_regex defines several constants that govern general regex matching syntax.
文本通過谷歌翻譯機器翻譯。
你可以幫忙校正和驗證翻譯。點擊此處查看指示。
。這些常量重複std::regex_constants
原文:
These constants are duplicated from std::regex_constants:
文本通過谷歌翻譯機器翻譯。
你可以幫忙校正和驗證翻譯。點擊此處查看指示。
文法選項 效果
ECMAScript 使用有改動的 ECMAScript 正則表達式文法
basic 使用基本 POSIX 正則表達式文法(文法文檔)。
extended 使用擴展 POSIX 正則表達式文法(文法文檔)。
awk 使用 POSIX 中 awk 工具所用的正則表達式文法(文法文檔)。
grep 使用 POSIX 中 grep 工具所用的正則表達式文法。這相當於 basic 選項,附帶以換行符 '\n' 作為另一種分隔符。
egrep 使用 POSIX 中 grep 工具帶 -E 選項所用的正則表達式文法。這相當於 extended 選項,附帶以換行符 '\n' 作為 '|' 之外的另一種分隔符。
文法變體 效果
icase 應當以不考慮大小寫進行字符匹配。
nosubs 進行匹配時,將所有被標記的子表達式 (expr) 當做非標記的子表達式 (?:expr)。不將匹配存儲於提供的 std::regex_match 結構中,且 mark_count() 為零。
optimize 指示正則表達式引擎進行更快的匹配,帶有令構造變慢的潛在開銷。例如這可能表示將非確定有限狀態機轉換為確定有限狀態機。
collate 形如 "[a-b]" 的字符範圍將對本地環境敏感。
multiline (C++17) 如果選擇 ECMAScript 引擎,那麼指定 ^ 應該匹配行首,而 $ 應該匹配行尾。

在文法選項 ECMAScriptbasicextendedawkgrepegrep 中最多只能選取一個。當未選擇文法時假定選取 ECMAScript。其他選項作為文法變體生效,從而 std::regex("meow", std::regex::icase) 等價於 std::regex("meow", std::regex::ECMAScript|std::regex::icase)

。另請參閱。

Template:cpp/regex/dcl list syntax option type