[Wellington-pm] capturing quantified matches

Richard Hector richard at walnut.gen.nz
Tue Oct 4 14:42:05 PDT 2011


On Wed, 2011-10-05 at 08:53 +1300, Grant McLean wrote:

> One alternative approach is to use two matches with the second one
> picking up at the end of the first:
> 
>   my $str = 'one two three four five';
> 
>   my @match1 = $str =~ /^(\w+) (\w+)/gc;
> 
>   print Dumper(\@match1);
> 
>   my @match2 = $str =~ /\G (\w+)/g;
> 
>   print Dumper(\@match2);

Interesting, thanks - I'll have to study/play with /gc a bit to
understand it, I think :-) But \G looks handy.

Richard




More information about the Wellington-pm mailing list