public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "georg@schorsch-tech.de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/66359] New: Regex Fails to match
Date: Mon, 01 Jun 2015 09:53:00 -0000	[thread overview]
Message-ID: <bug-66359-4@http.gcc.gnu.org/bugzilla/> (raw)

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.


             reply	other threads:[~2015-06-01  9:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-01  9:53 georg@schorsch-tech.de [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-66359-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).