64,685
社区成员
发帖
与我相关
我的任务
分享
int main(int argc, char* argv[])
{
try
{
std::string dateStr = "2018-03-13";
printf("111\n");
std::regex dateReg("\d{4}-\d{2}-\d{2}");
//std::regex dateReg("[0-9]{4}-[0-9]{2}-[0-9]{2}");
printf("222\n");
if (std::regex_match(dateStr, dateReg))
{
printf("true\n");
}
else
{
printf("false\n");
}
}
catch (const std::regex_error& err)
{
printf("%d, %s\n", err.code(), err.what());
}
return 0;
}
std::regex_constants::error_type
C++ Regular expressions library
Defined in header <regex>
typedef /*implementation defined*/ error_type;
(since C++11)
constexpr error_type error_collate = /*unspecified*/;
constexpr error_type error_ctype = /*unspecified*/;
constexpr error_type error_escape = /*unspecified*/;
constexpr error_type error_backref = /*unspecified*/;
constexpr error_type error_brack = /*unspecified*/;
constexpr error_type error_paren = /*unspecified*/;
constexpr error_type error_brace = /*unspecified*/;
constexpr error_type error_badbrace = /*unspecified*/;
constexpr error_type error_range = /*unspecified*/;
constexpr error_type error_space = /*unspecified*/;
constexpr error_type error_badrepeat = /*unspecified*/;
constexpr error_type error_complexity = /*unspecified*/;
constexpr error_type error_stack = /*unspecified*/;
(since C++11)
(until C++17)
inline constexpr error_type error_collate = /*unspecified*/;
inline constexpr error_type error_ctype = /*unspecified*/;
inline constexpr error_type error_escape = /*unspecified*/;
inline constexpr error_type error_backref = /*unspecified*/;
inline constexpr error_type error_brack = /*unspecified*/;
inline constexpr error_type error_paren = /*unspecified*/;
inline constexpr error_type error_brace = /*unspecified*/;
inline constexpr error_type error_badbrace = /*unspecified*/;
inline constexpr error_type error_range = /*unspecified*/;
inline constexpr error_type error_space = /*unspecified*/;
inline constexpr error_type error_badrepeat = /*unspecified*/;
inline constexpr error_type error_complexity = /*unspecified*/;
inline constexpr error_type error_stack = /*unspecified*/;
(since C++17)
The error_type is a type that describes errors that may occur during regular expression parsing.
Constants
Constant Explanation
error_collate the expression contains an invalid collating element name
error_ctype the expression contains an invalid character class name
error_escape the expression contains an invalid escaped character or a trailing escape
error_backref the expression contains an invalid back reference
error_brack the expression contains mismatched square brackets ('[' and ']')
error_paren the expression contains mismatched parentheses ('(' and ')')
error_brace the expression contains mismatched curly braces ('{' and '}')
error_badbrace the expression contains an invalid range in a {} expression
error_range the expression contains an invalid character range (e.g. [b-a])
error_space there was not enough memory to convert the expression into a finite state machine
error_badrepeat one of *?+{ was not preceded by a valid regular expression
error_complexity the complexity of an attempted match exceeded a predefined level
error_stack there was not enough memory to perform a match