[prev in list] [next in list] [prev in thread] [next in thread]
List: perl-beginners
Subject: multiple named captures with a single regexp
From: Luca Ferrari <fluca1978 () infinito ! it>
Date: 2017-03-01 9:01:34
Message-ID: CAKoxK+75KXYJpSGf+2mQksvxq_3w0Cend41L9xLTQh7+Rn6f7g () mail ! gmail ! com
[Download RAW message or body]
Hi all,
I'm not sure if this is possible, but imagine I've got a line as follows:
command arg1 arg2 arg3 arg4 ...
I would like to capture all args with a single regexp, possibly with a
named capture, but I don't know exactly how to do:
my $re = qr/command\s+(?<arg>\w+)+/;
the above of course is going to capture only the first one (one shoot)
or the last one within a loop.
How can I extract the whole array of arguments?
Please note, a raw solution is to remove the command and split, but
I'm asking for a more elegant solution.
Thanks,
Luca
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic