1

I am trying to use really straightforward regular expressions to match strings like 2001M12. I create a std::regex object as follows:

std::regex gretlMonth("^[:d:]{4}M[:d:]{2}$");

but I get the following runtime exception on this line:

unknown location(0): fatal error in "Plot_GuessesTimeFormat": std::runtime_error: regex_error

What am I doing wrong?

0

2 Answers 2

3

If you're using gcc, libstdc++ has not yet implemented regex.

http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.2011

See also:

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

Sign up to request clarification or add additional context in comments.

2 Comments

Crap! Is this functionality also available in boost?
Yes. It's available in either boost or libc++ (from clang)
0

maybe your regex string is incorrect and try this "^\d{4}M\d{2}$".

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.