0
bool match=0;
string pattern, domain="sub1.example.org";
while(res->next())
{
   pattern.append("(.+\\.)?");
   pattern.append(res->getString(1));
   std::regex RE(pattern);
   cout << pattern << "-" << domain << endl;
   pattern.clear();
   if((match=regex_match(domain, RE)))
      break;
}

That one above does not match, altough output is this:

(.+\.)?example.org-sub1.example.org
(.+\.)?example.orgg-sub1.example.org
(.+\.)?sdasd.com-sub1.example.org

I guess I am too sleepy or something, can somebody help me out?

EDIT: gcc 4.6.3

Etherealone
  • 3,488
  • 2
  • 37
  • 56

2 Answers2

2

GNU libstdc++'s implementation of <regex> is incomplete. See the manual.

rubenvb
  • 74,642
  • 33
  • 187
  • 332
  • Or Microsoft. Their implementation is complete. – Pete Becker Aug 28 '12 at 01:16
  • 1
    @PeteBecker MS is hardly an option for decent C++11 language support, nor cross-platformness. – rubenvb Aug 28 '12 at 10:38
  • @rubenvb - uh, yes, one problem with "cross-platformness" as it relates to regex is that MS has a complete implementation and gcc doesn't. Sure makes it hard to port standard-conforming code from MS to gcc. – Pete Becker Aug 28 '12 at 12:15
  • @PeteBecker as the OP says: Boost. No issues there. – rubenvb Aug 28 '12 at 13:31
  • @rubenvb - umm, one issue is that Boost requires separate installation and maintenance, while the standard version comes with the compiler. – Pete Becker Aug 28 '12 at 13:40
  • @PeteBecker Just include the Boost stuff in your project. No maintenance. No hassle, works everywhere. – rubenvb Aug 28 '12 at 14:54
1

Looks like a bug in the implementation. I get the same result, but if I remove the '?' from the regular expression it matches. I can't think of any reason that saying "0 or 1 of these" instead of "1 of these" would fail when the latter succeeds.

Pete Becker
  • 74,985
  • 8
  • 76
  • 165