https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98505

            Bug ID: 98505
           Summary: Capture groups under quantifier must capture only last
                    match
           Product: gcc
           Version: 8.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: asorenji at gmail dot com
  Target Milestone: ---

I'm not sure if this bug or not, but in regex ((a)|(b))* with ECMAScript flavor
and text "ab" I get second and third group matched in one time. If I run same
test in https://regex101.com/ with ECMAScript flavor, only third group matched
https://regex101.com/r/66otHS/1/ (yes, for other flavors both group matched).
Let's assume that both group should matched. Second group for first char, third
group for second char. Then why can't I compile (a|b\\1)* expression with same
logic for "aba" text? If this expression incorrect, then this tricks don't
planned.

std::regex regex("((a)|(b))*",std::regex_constants::ECMAScript);
std::match_results<const char*> results;
if(std::regex_search("ab",results,regex))
    //1 1 as result
    std::cout<<results[2].matched<<" "<<results[3].matched<<std::endl;

Reply via email to