Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: regex (between two words)

by LanX (Saint)
on Feb 09, 2020 at 22:13 UTC ( [id://11112703]=note: print w/replies, xml ) Need Help??


in reply to Re^2: regex (between two words)
in thread regex (between two words)

> I think I'd rather prefer splitting the longest match ...

DB<205> p $_ = join " ", map { "$_" x 3 } qw/. a b C a d C e C ./ ... aaa bbb CCC aaa ddd CCC eee CCC ... DB<206> p ($long) = /(aaa.*CCC)/ aaa bbb CCC aaa ddd CCC eee CCC DB<207> $last = "" DB<208> x map {$last .= $_ } split /(?<=CCC)/, $long 0 'aaa bbb CCC' 1 'aaa bbb CCC aaa ddd CCC' 2 'aaa bbb CCC aaa ddd CCC eee CCC' DB<209>

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

Log In?
Username:
Password:

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

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

    No recent polls found