Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Perl6 global regex matching

by moritz (Cardinal)
on Oct 20, 2015 at 10:29 UTC ( [id://1145405]=note: print w/replies, xml ) Need Help??


in reply to Perl6 global regex matching

There's not much use in doing a global regex match with an anchored regex.

Furthermore, a global regex match returns a list of matches, so use a for-loop to iterate over them:

use v6; my $line = '124des123'; for $line ~~ m:g/ \d ** 2..3 / -> $match { say ~$match; }

Output:

124 123

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-04-25 14:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found