Re: multiple named captures with a single regexp

2017-03-01 Thread Chas. Owens
/(\w+)/g gets the command as well and only the args are wanted, so it would need to be my @args = $s =~ / (\w+)/g; shift @args; also, my VAR if TEST; is deprecated IIRC and slated to be removed soon (as it's behavior is surprising). It would probably be better to say my @args = $s =~ /^\w+\s/

Re: multiple named captures with a single regexp

2017-03-01 Thread X Dungeness
On Wed, Mar 1, 2017 at 2:52 AM, Chas. Owens wrote: > Sadly, Perl will only capture the last match of capture with a qualifier, so > that just won't work. The split function really is the simplest and most > elegant solution for this sort of problem (you have a string with a > delimiter and you wa

Re: multiple named captures with a single regexp

2017-03-01 Thread Chas. Owens
Sadly, Perl will only capture the last match of capture with a qualifier, so that just won't work. The split function really is the simplest and most elegant solution for this sort of problem (you have a string with a delimiter and you want the pieces). All of that said, if you are willing to mod

Re: multiple named captures with a single regexp

2017-03-01 Thread Shlomi Fish
Hi Luca, On Wed, 1 Mar 2017 10:01:34 +0100 Luca Ferrari wrote: > 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

multiple named captures with a single regexp

2017-03-01 Thread Luca Ferrari
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+(?\w+)+/; the above of course is goin