std::basic_regex 常量

定义于头文件 <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;

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 工具所用的正则表达式文法。这等效于 basic 选项附带作为另一种分隔符的换行符 '\n' 。
egrep 使用 POSIX 中 grep 工具带 -E 选项所用的正则表达式文法。这等效于 extended 附带 '|' 之外的作为另一种分隔符的换行符 '\n' 。

ECMAScript, basic, extended, awk, grep, egrep 必须选取至多一个文法选项。若不选取文法选项,则设定为选取 ECMAScript 。其他选项作为修饰符工作,从而 std::regex("meow", std::regex::icase) 等价于 std::regex("meow", std::regex::ECMAScript|std::regex::icase)

参阅

控制正则表达式行为的通用选项
(typedef)

版本历史

  • (当前 | 先前 2017年6月16日 (五) 06:29Fruderica讨论 | 贡献. . (1,447字节) (-464). . (撤销)
  • 当前 | 先前 2013年7月2日 (二) 09:30P12bot讨论 | 贡献 . . (1,911字节) (-52). . (Use {{lc}}. Update links. Various fixes.) (撤销)
  • 当前 | 先前 2012年11月2日 (五) 12:47P12bot讨论 | 贡献 . . (1,963字节) (+313). . (r2.7.3) (机器人添加:de, en, es, fr, it, ja, pt, ru) (撤销)
  • 当前 | 先前 2012年10月27日 (六) 09:06P12讨论 | 贡献 . . (1,650字节) (0). . (1个修订: Translate from the English version) (撤销)
  • 当前 | 先前 2012年10月26日 (五) 06:00TranslationBot讨论 | 贡献. . (1,650字节) (-16). . (Translated from the English version using Google Translate) (撤销)
  • 当前 | 先前 2012年10月25日 (四) 15:32P12讨论 | 贡献 . . (1,666字节) (0). . (1个修订: Translate from the English version) (撤销)
  • 当前 | 先前) 2012年10月25日 (四) 12:00TranslationBot讨论 | 贡献. . (1,666字节) (+1,666). . (Translated from the English version using Google Translate)