名前空間
変種
操作

std::basic_regex の定数

提供: cppreference.com
< cpp‎ | regex‎ | basic regex
ヘッダ <regex> で定義
staticconstexprstd::regex_constants::syntax_option_type icase =

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

    std::regex_constants::egrep;
staticconstexprstd::regex_constants::syntax_option_type multiline =
    std::regex_constants::multiline;
(C++17以上)

std::basic_regex は一般的な正規表現マッチングの構文に影響を与えるいくつかの定数を定義しています。

これらの定数は std::regex_constants からの複製です。

効果
icase 大文字小文字を考慮せずに文字のマッチングを行います。
nosubs マッチを行うとき、すべてのマーク付き部分表現 (expr) を、マークなしの部分表現 (?:expr) として扱います。 供給された std::regex_match 構造体に格納されるマッチはなく、 mark_count() はゼロになります。
optimize 構築が遅くなる可能性があっても、マッチングを高速化するよう、正規表現エンジンに指示します。 例えば、これは非決定的 FSA を決定的 FSA に変換することを意味するかもしれません。
collate"[a-b]" 形式の文字範囲をロケール対応にします。
multiline(C++17) ECMAScript エンジンが選択された場合、 ^ を行頭にマッチさせ、 $ を行末にマッチさせます。
ECMAScript修正 ECMAScript 正規表現文法を使用します。
basic 基本 POSIX 正規表現文法を使用します (文法のドキュメント)。
extended 拡張 POSIX 正規表現文法を使用します (文法のドキュメント)。
awk POSIX の awk ユーティリティで使用される正規表現文法を使用します (文法のドキュメント)。
grep POSIX の grep ユーティリティで使用される正規表現文法を使用します。 これは実質的に代替区切り文字として改行 '\n' を追加した basic オプションと同じです。
egrep POSIX の grep ユーティリティで -E オプションを付けたときに使用される正規表現文法を使用します。 これは実質的に代替区切り文字として '|' に加えて改行 '\n' を追加した extended オプションと同じです。

ECMAScriptbasicextendedawkgrepegrep のうち高々ひとつの文法オプションだけを選択できます。 文法を選択しない場合は ECMAScript が選択されたと仮定されます。 他のオプションは修飾子として働きます。 例えば std::regex("meow", std::regex::icase)std::regex("meow", std::regex::ECMAScript|std::regex::icase) と同等です。

[編集]関連項目

正規表現の動作を制御する一般的なオプション
(typedef)[edit]
close