std::basic_regex constants

来自cppreference.com
< cpp‎ | regex‎ | basic regex
2012年10月25日 (四) 13:00TranslationBot讨论 | 贡献的版本

(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

 
 
 
正则表达式库
(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