Etherealone
Etherealone

Reputation: 3558

C++11 RegEx Matching - I can't get it to work properly

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

Upvotes: 0

Views: 259

Answers (2)

rubenvb
rubenvb

Reputation: 76519

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

Upvotes: 2

Pete Becker
Pete Becker

Reputation: 76305

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.

Upvotes: 1

Related Questions