in reply to [RE] match positions of named captures?
The named captures (or resulting hashes) do not have a relation to the actual position of the place where the group is defined. I think the whole intend of the module has a different purpose and I doubt the developer had group position in mind.
In the example that follows the results in this particular case foo and bar come from two different groups. How do you expect to get a position for that named group?
use strict ; use warnings ; use Data::Dumper ; my $str = "abcdef" ; $str =~ /(?<foo>[ab])*(?<bar>c)(?<foo>d)(?<bar>[ef]*)/ ; print Dumper(\%-) ;
$VAR1 = { 'foo' => [ 'b', 'd' ], 'bar' => [ 'c', 'ef' ] };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: [RE] match positions of named captures?
by LanX (Saint) on Dec 02, 2019 at 17:13 UTC |