在线文档教程
C++
规律表达 | Regular expressions

std::basic_regex

性病:基本[医]雷吉

Defined in header
template < class CharT, class Traits = std::regex_traits<CharT> > class basic_regex;(since C++11)

类模板basic_regex提供用于保存正则表达式的通用框架。

提供了几种常见字符类型的专门化:

在标头中定义<regex>

*。

类型定义

正则基[医]雷吉<char>

圈基[医]regex<wchar[医]T>

成员类型

Member typeDefinition
value_typeCharT
traits_typeTraits
string_typeTraits::string_type
locale_typeTraits::locale_type
flag_typestd::regex_constants::syntax_option_type

成员函数

(constructor)constructs the regex object (public member function)
(destructor)destructs the regex object (public member function)
operator=assigns the contents (public member function)
assignassigns the contents (public member function)

观察员

马克[医]Count返回正则表达式%28公共成员函数中标记的子表达式数%29。

标志返回语法标志%28公共成员函数%29

现场

获取地区信息%28公共成员函数%29

注入设置地区信息%28公共成员函数%29

修饰符

交换交换内容%28公共成员函数%29

常数

ValueEffect(s)
icaseCharacter matching should be performed without regard to case.
nosubsWhen performing matches, all marked sub-expressions (expr) are treated as non-marking sub-expressions (?:expr). No matches are stored in the supplied std::regex_match structure and mark_count() is zero
optimizeInstructs the regular expression engine to make matching faster, with the potential cost of making construction slower. For example, this might mean converting a non-deterministic FSA to a deterministic FSA.
collateCharacter ranges of the form "a-b" will be locale sensitive.
multiline (C++17)Specifies that ^ shall match the beginning of a line and $ shall match the end of a line, if the ECMAScript engine is selected.
ECMAScriptUse the Modified ECMAScript regular expression grammar
basicUse the basic POSIX regular expression grammar (grammar documentation).
extendedUse the extended POSIX regular expression grammar (grammar documentation).
awkUse the regular expression grammar used by the awk utility in POSIX (grammar documentation)
grepUse the regular expression grammar used by the grep utility in POSIX. This is effectively the same as the basic option with the addition of newline '\n' as an alternation separator.
egrepUse the regular expression grammar used by the grep utility, with the -E option, in POSIX. This is effectively the same as the extended option with the addition of newline '\n' as an alternation separator in addtion to '|'.

最多只能选择一个语法选项。ECMAScript,,,basic,,,extended,,,awk,,,grep,,,egrep如果没有选择语法,ECMAScript被假定是被选中的。其他选项用作修饰符,例如std::regex("meow", std::regex::icase)等于std::regex("meow", std::regex::ECMAScript|std::regex::icase)...

中的成员常量basic_regex是句法[医]期权[医]类型命名空间中定义的常量std::regex_constants...

非会员职能

std::swap(std::basic_regex) (C++11)specializes the std::swap algorithm (function template)

© cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

http://en.cppreference.com/w/cpp/regex/basic[医]雷吉