Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: regex (between two words)

by tybalt89 (Monsignor)
on Feb 09, 2020 at 15:54 UTC ( [id://11112689]=note: print w/replies, xml ) Need Help??


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)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11112689]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-04-18 17:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found