in reply to Greedy modifier found to be working non-greedy in a named group

To conclude, the explanation of leftmost first and then longest will be valid even if I didn't use named groups.

So, for example,

$_ = "This is a teeeext for testting"; /(e*)/ and print "'$1' is matched pattern\n"; # gives '' is matched pattern
and
$_ = "This is a teeeext for testting"; /(e+)/ and print "'$1' is matched pattern\n"; # gives 'eeee' is matched pattern

So, this behavior is generic.

Replies are listed 'Best First'.
Re^2: Greedy modifier found to be working non-greedy in a named group
by haukex (Archbishop) on Nov 29, 2019 at 21:08 UTC
    the explanation of leftmost first and then longest will be valid even if I didn't use named groups. So, this behavior is generic.

    Yes, perlre says:

    In Perl the groups are numbered sequentially regardless of being named or not. Thus in the pattern
    /(x)(?<foo>y)(z)/
    $+{foo} will be the same as $2, and $3 will contain 'z'

    And the description of (?|pattern) says:

    Named captures are implemented as being aliases to numbered groups holding the captures

    Also, I remember finding the description of the left-to-right operation of the regex engine in the Camel quite enlightening.