In Ruby you can extract the named captured groups of a regex using the names
method:
/(?<foo>.)(?<bar>.)(?<baz>.)/.names
#=> ["foo", "bar", "baz"]
Is there a Perl equivalent for such method? I could extract the names doing something like this:
while ( $re =~ m/\?<(.+?)>/g ) {
say $1;
}
But I don't know how robust/efficient/elegant that solutions is.
EDITED: I know that you can get the names after a match but I need to extract the names before using the regex.