in reply to regex (between two words)

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11112687 use warnings; $_ = 'aaa bbb ccc ddd ccc eee'; my @qqq; /(aaa.*?ccc)(?{push @qqq, $&})(*F)/g; print join("\n", @qqq, '');

Outputs

aaa bbb ccc aaa bbb ccc ddd ccc

Replies are listed 'Best First'.
Re^2: regex (between two words)
by nickwest (Initiate) on Feb 09, 2020 at 15:59 UTC
    Great! Thank you very much!
Re^2: regex (between two words)
by LanX (Saint) on Feb 09, 2020 at 21:14 UTC
    If there is more than one aaa this approach would try to match all possible combination intervals, right?

    Not sure if the OP only wants to start from the first aaa

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

      All possible combinations, yes.

      This solution *is* correct because it passes all the provided test cases. (hehehe)