Steffen Nurpmeso wrote, on 24 Sep 2024: > > Austin Group Bug Tracker via austin-group-l at The Open Group wrote in > <[email protected]>: > ... > |https://austingroupbugs.net/view.php?id=1857 > ... > | (0006881) geoffclare (manager) - 2024-09-24 10:46 > | https://austingroupbugs.net/view.php?id=1857#c6881 > ... > > I have not yet read this completely, but from a glance i see > > the ERE "(aaa??)*" matches only the first four characters of the > string "aaaaa", not all five, because in order to match all > five, "a??" would match with length one instead of zero > > and that felt not right: > > echo 'aaaaa' | > perl -e '$i=<STDIN>;if($i =~ "(aaa??)*"){print "i<$i>; 1<$1> 2<$2> > 3<$3>\n"}else{print "no match\n"}' > i<aaaaa > >; 1<aa> 2<> 3<> > > It matches only two.
Looks like a bug in perl. Each repetition of "aaa??" matches "aa" because the "??" is non-greedy, but the "*" is greedy so should match the longest string of repeated "aa" as possible. With regcomp() on macOS it matches "aaaa", as expected. (That example is straight from the macOS re_format(7) man page, but I also tested it to make sure.) -- Geoff Clare <[email protected]> The Open Group, Apex Plaza, Forbury Road, Reading, RG1 1AX, England
