Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding std::regex declaration : regex_error exception at runtime [duplicate]

Tags:

c++

regex

c++11

I have the following executable. I compile it with gcc 4.7.2 (g++ foo.cc -std=c++11).

At run time, the exception regex_error is thrown.

What am I doing wrong ?

#include <regex>

int main(int, char**){
    std::regex re("\\d");
}

UPDATE The error code in the exception is error_escape. So I tried "\\d". It doesn't fail at runtime, but I doesn't match againt "1", but it DOES match "\d". So this is clearly not what I want

like image 419
Tristram Gräbener Avatar asked Apr 07 '26 11:04

Tristram Gräbener


1 Answers

So the answer seem to be that the implementation in the GCC4.7 STL is incomplete. Thank you all for your comments.

No matches with c++11 regex

Thank you soon and Nathan Ernst !

like image 122
Tristram Gräbener Avatar answered Apr 09 '26 02:04

Tristram Gräbener