https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66359
Bug ID: 66359 Summary: Regex Fails to match Product: gcc Version: 4.9.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: ge...@schorsch-tech.de Target Milestone: --- // #define USE_STD #ifdef USE_STD #include <regex> #else #include <boost/regex.hpp> #endif #include <iostream> #include <string> #ifdef USE_STD namespace rx = std; #else namespace rx = boost; #endif int main(int argc, char* argv[]) { std::string line{ "Name:\tPiko_10_1 " }; rx::regex line_expression("^Name:\t {0,2}([a-zA-Z_0-9-]{1,20}) {0,20}$"); rx::match_results<std::string::const_iterator> line_what; if (rx::regex_match(line, line_what, line_expression)) { std::cout << "Found it" << std::endl; } else { std::cout << "ERROR: Did not find it" << std::endl; return 1; } return 0; } Compile with: std: g++ --std=c++11 main.cpp -o test-std.exe Boost: g++ --std=c++11 main.cpp -o test-boost.exe -I PATH_TO_BOOST_INCLUDE _L PATH_TO_BOOST_REGEX_LIB I tried to convert an application from boost:.regex to std::regex. This example is the boiled down example from my application. With the define USE_STD defined, i get the error that this regex doesnt match. With boost::regex i get a match. I tried this regex on TDM-GCC-4.9.2 and on Linux gcc-4.9.2 (gentoo). I know regex is not implemented Prior 4.9.0. I am on 4.9.2 so i guess it should work. Other regexes like std::regex line_expression("([a-zA-Z_]+) ?= ?([a-zA-Z0-9./]+)"); work as expected.