PCRE has the /U flag that reverses the behavior of .* and .*? ( *PCRE_UNGREEDY)*
This was always a terrible idea, and is probably the source of your confusion. On Fri, Aug 4, 2017 at 12:38 PM, Brandon Allbery <allber...@gmail.com> wrote: > Like I said, greedy is the default, *.? says *don't* be greedy. You wanted > .* for greedy match. But even with that, the extra .* before the f was > telling it to eat stuff (greedily, since no ?, so it out-greed-ed the > captured non-greedy .*?). > > > On Friday, August 4, 2017, ToddAndMargo <toddandma...@zoho.com> wrote: > >> On Friday, August 4, 2017, ToddAndMargo <toddandma...@zoho.com <mailto: >>>> toddandma...@zoho.com>> wrote: >>>> >>>> Hi All, >>>> >>>> I NEED TO BE GREEDY! HAHA HAHA <miniacle laughter continues>. >>>> >>>> Okay, I am back in control of myself (for the moment). >>>> >>>> What am I doing wrong here? >>>> >>>> perl6 -e 'my $x="a b c d e f"; $x ~~ m/.*?(c.*?).*f/; say "<$0>";' >>>> <c> >>>> >>>> I am after >>>> <c d e > >>>> >>>> I want the space at the end too >>>> >>> >> On 08/04/2017 12:30 PM, Brandon Allbery wrote: >> >>> The ? is the opposite of greedy, just as in pcre/perl 5. Greedy is the >>> default. I also don't see why you have a .* before f if you want to capture >>> everything before the f. >>> >>> >> Huh??? <maniacal laughter stops>. Oh poop. You called it. >> >> >> With the space: >> $ perl6 -e 'my $x="a b c d e f"; $x ~~ m/(c.*?)f/; say "<$0>";' >> <c d e > >> >> Without the space: >> $ perl6 -e 'my $x="a b c d e f"; $x ~~ m/(c.*?)" "f/; say "<$0>";' >> <c d e> >> >> Thank you! >> >> And just when I thought I had an excuse to be greedy. :'( >> > > > -- > brandon s allbery kf8nh sine nomine > associates > allber...@gmail.com > ballb...@sinenomine.net > unix, openafs, kerberos, infrastructure, xmonad > http://sinenomine.net > >