I have the following piece of code:
#include <regex>
#include <exception>
#include <iostream>
int main(int argc, char *argv[])
{
std::regex reg;
try{
reg = std::regex(".*[a-zA-Z]+.*");
}
catch(std::regex_error &e){
std::cout << e.what() << std::endl;
std::cout << e.code() << std::endl;
if (e.code() == std::regex_constants::error_brack)
std::cerr << "The expression contained mismatched brackets ([ and ]).\n";
}
return 0;
}
And this gives me :
regex_error
4
The expression contained mismatched brackets ([ and ]).
What am I doing wrong ? I am using g++ 4.8.2 with -std=c++11
flag.
EDIT I get the same on ideone http://ideone.com/SDqv0e so it's not the compiler.