public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/98505] New: Capture groups under quantifier must capture only last match
@ 2021-01-03 14:53 asorenji at gmail dot com
  0 siblings, 0 replies; only message in thread
From: asorenji at gmail dot com @ 2021-01-03 14:53 UTC (permalink / raw)
  To: gcc-bugs

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;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-01-03 14:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-03 14:53 [Bug libstdc++/98505] New: Capture groups under quantifier must capture only last match asorenji at gmail dot com

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