On Friday, August 4, 2017, ToddAndMargo <[email protected] <mailto:[email protected]>> 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. :'(
