On 25/09/2024 09:15, Geoff Clare via austin-group-l at The Open Group wrote:
Steffen Nurpmeso wrote, on 24 Sep 2024:

Austin Group Bug Tracker via austin-group-l at The Open Group wrote in
  <ea7880ce68ba63cac427845dc4029...@austingroupbugs.net>:
  ...
  |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.

It isn't. It's just that Steffen gave a false representation of what perl does.

                           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.

It does. But the example never shows what it matches. Of course the output then isn't going to include the match. The match is available in $&. What's in $1 is the first (the only) capture.

perl does match "aaaa".

Cheers,
Harald van Dijk

  • [1003.1(2024... Austin Group Bug Tracker via austin-group-l at The Open Group
  • [1003.1(2024... Austin Group Bug Tracker via austin-group-l at The Open Group
    • Re: [10... Niu Danny via austin-group-l at The Open Group
    • Re: [10... Niu Danny via austin-group-l at The Open Group
      • Re:... Geoff Clare via austin-group-l at The Open Group
        • ... Niu Danny via austin-group-l at The Open Group
          • ... Geoff Clare via austin-group-l at The Open Group
  • [1003.1(2024... Austin Group Bug Tracker via austin-group-l at The Open Group
    • Re: [10... Steffen Nurpmeso via austin-group-l at The Open Group
      • Re:... Geoff Clare via austin-group-l at The Open Group
        • ... Harald van Dijk via austin-group-l at The Open Group
        • ... Garrett Wollman via austin-group-l at The Open Group
          • ... Steffen Nurpmeso via austin-group-l at The Open Group
          • ... Geoff Clare via austin-group-l at The Open Group
            • ... Geoff Clare via austin-group-l at The Open Group
        • ... Steffen Nurpmeso via austin-group-l at The Open Group
  • [1003.1(2024... Austin Group Bug Tracker via austin-group-l at The Open Group
  • [1003.1(2024... Austin Group Bug Tracker via austin-group-l at The Open Group
  • [1003.1(2024... Austin Group Bug Tracker via austin-group-l at The Open Group
  • [1003.1(2024... Austin Group Bug Tracker via austin-group-l at The Open Group
    • Re: [10... Niu Danny via austin-group-l at The Open Group

Reply via email to