From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 74466 invoked by alias); 1 Jun 2015 09:53:05 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 74442 invoked by uid 48); 1 Jun 2015 09:53:00 -0000 From: "georg@schorsch-tech.de" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/66359] New: Regex Fails to match Date: Mon, 01 Jun 2015 09:53:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 4.9.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: georg@schorsch-tech.de X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-06/txt/msg00014.txt.bz2 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: georg@schorsch-tech.de Target Milestone: --- // #define USE_STD #ifdef USE_STD #include #else #include #endif #include #include #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 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.