```{index} single: regnames; re function ``` ```{index} single: re::regnames; Perl function ``` # regnames Return the names of the named capture groups in the most recent successful match. With no argument (or a false one), you get the names that were actually visited during the match. With a truthy argument, you get every name declared by the pattern, whether or not it participated. ## Synopsis ```perl use re 'regnames'; "foobar" =~ /(?foo)(?bar)/; my @used = regnames(); # names that participated in the match my @all = regnames(1); # every name declared in the pattern ``` ## What you get back A flat list of names in pattern order. If there was no prior successful match in the current scope, or the pattern has no named captures at all, returns `undef`. ## Examples ```perl "abc" =~ /(?a)(?b)(?c)/; my @n = regnames(); # ('first', 'second', 'third') "abc" =~ /(?x)|(?b)/; # branch reset-style duplicate name my @n = regnames(); # ('a') — one entry per distinct name my @n = regnames(1); # all declared, even unmatched ``` ## Edge cases - No prior successful match — returns `undef`. - Pattern has no named captures — returns `undef`. - Duplicate names (from branch-reset or multiple alternatives) appear once; use `regname($name, 1)` to see every value.