public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/66359] New: Regex Fails to match
@ 2015-06-01  9:53 georg@schorsch-tech.de
  2015-06-01  9:54 ` [Bug libstdc++/66359] " georg@schorsch-tech.de
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: georg@schorsch-tech.de @ 2015-06-01  9:53 UTC (permalink / raw)
  To: gcc-bugs

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 <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.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-07-20 11:47 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-01  9:53 [Bug libstdc++/66359] New: Regex Fails to match georg@schorsch-tech.de
2015-06-01  9:54 ` [Bug libstdc++/66359] " georg@schorsch-tech.de
2015-06-01 11:46 ` timshen at gcc dot gnu.org
2015-06-01 15:19 ` georg@schorsch-tech.de
2015-06-01 15:25 ` georg@schorsch-tech.de
2015-06-05  4:59 ` timshen at gcc dot gnu.org
2015-06-05  5:06 ` timshen at gcc dot gnu.org
2023-07-20 11:47 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).