名前空間
変種
操作

std::basic_regex 定数

From cppreference.com
< cpp‎ | regex‎ | basic regex
 
 
 
正規表現ライブラリ
クラス
(C++11)
アルゴリズム
イテレータ
例外
Traits
定数
(C++11)
正規表現文法
 
 
ヘッダ <regex> で定義
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;
(C++17以降)

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

これらの定数は std::regex_constants から複製されています。

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

ECMAScriptbasicextendedawkgrepegrep のうち、最大 1 つの文法オプションを選択できます。文法が選択されていない場合、ECMAScript が選択されたとみなされます。その他のオプションはバリエーションとして機能するため、std::regex("meow", std::regex::icase)std::regex("meow", std::regex::ECMAScript|std::regex::icase) と同等です。

[編集] 関連項目

正規表現の振る舞いを制御する一般的なオプション
(typedef) [編集]
English 日本語 中文(简体) 中文(繁體)