regnames_count#
Return the number of distinct named capture groups in the pattern of the most recent successful match.
The count is always the number of distinct names defined in the pattern - it does not depend on which names participated in the match, and it does not necessarily match the length of what regnames() returns when that is called without its $all argument.
Σύνοψη#
use re 'regnames_count';
"abc" =~ /(?<a>x)|(?<b>b)/;
my $n = regnames_count(); # 2
Τι επιστρέφεται#
An integer count, or undef if there was no prior successful match in the current scope.
Παραδείγματα#
"foobar" =~ /(?<w>\w+)/;
print regnames_count(); # 1
"abc" =~ /(?<a>.)(?<b>.)(?<a>.)/; # duplicate name 'a'
print regnames_count(); # 2 - counts distinct names
Οριακές περιπτώσεις#
No prior successful match - returns
undef.Pattern has no named captures - returns
0.