Subject: | Named captures unavailable in %+ |
The following test script fails when I wouldn't expect it to. %+ should
be holding the named captures, even when the RE2 engine is used.
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use re::engine::RE2;
my $re1 = qr/(?<name>foo)/;
my $re2 = qr/(?P<name>foo)/;
my $string = 'abcdefoo';
{
ok !$re1->isa('re::engine::RE2'), q{Perl's regex engine used};
ok $string =~ $re1, 'regex matches';
ok $1, 'match extracted';
is $1, 'foo', 'match is correct';
ok $+{name}, 'named match extracted';
is $+{name}, $1, 'named matches numbered';
}
{
ok $re2->isa('re::engine::RE2'), q{RE2 regex engine used};
ok $string =~ $re2, 'regex matches';
ok $1, 'match extracted';
is $1, 'foo', 'match is correct';
ok $+{name}, 'named match extracted';
is $+{name}, $1, 'named matches numbered';
}
done_testing;