我正在尝试使用非常简单的正则表达式来匹配2001M12
之类的字符串。我创建了一个std::regex
对象,如下所示:
std::regex gretlMonth("^[:d:]{4}M[:d:]{2}$");
但是我在这一行得到了以下运行时异常:
unknown location(0): fatal error in "Plot_GuessesTimeFormat": std::runtime_error: regex_error
我做错了什么?
答案 0 :(得分:3)
如果您正在使用gcc,则libstdc ++尚未实现正则表达式。
http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.2011
另见:
Is gcc 4.8 or earlier buggy about regular expressions?
No matches with c++11 regex
C++0x regex in GCC
very basic regex scenario works different than my expectation on libstdc++-v3
C++11 RegEx Matching - I can't get it to work properly
No matches with c++11 regex
Regular Expressions misunderstanding or just broken implementation?
c++ std regex question mark issue
What is my mistake in this regular expression using std::regex
std::regex -- is there some lib that needs to be linked?
Error while trying to compile c++11 regex tutorial with Clang++ on Linux
Is this C++11 regex error me or the compiler?
C++11 Regex Grouping
答案 1 :(得分:0)
也许你的正则表达式字符串不正确并试试这个“^ \ d {4} M \ d {2} $”。