Skip to content

Commit 95b1020

Browse files
committed
perldiag, perlre: Clarify capture group name rules
1 parent b7b77ff commit 95b1020

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

pod/perldiag.pod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2867,8 +2867,9 @@ has since been undefined.
28672867
S<<-- HERE> in m/%s/
28682868

28692869
(F) Group names must follow the rules for perl identifiers, meaning
2870-
they must start with a non-digit word character. A common cause of
2871-
this error is using (?&0) instead of (?0). See L<perlre>.
2870+
that ASCII-range ones must start with a non-digit word character. A
2871+
common cause of this error is using (?&0) instead of (?0). See
2872+
L<perlre> and L<perldata/Identifier parsing>.
28722873

28732874
=item ()-group starts with a count
28742875

pod/perlre.pod

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1198,7 +1198,9 @@ You can dispense with numbers altogether and create named capture groups.
11981198
The notation is C<(?E<lt>I<name>E<gt>...)> to declare and C<\g{I<name>}> to
11991199
reference. (To be compatible with .Net regular expressions, C<\g{I<name>}> may
12001200
also be written as C<\k{I<name>}>, C<\kE<lt>I<name>E<gt>> or C<\k'I<name>'>.)
1201-
I<name> must not begin with a number, nor contain hyphens.
1201+
I<name> must follow the rules for perl identifiers
1202+
(L<perldata/Identifier parsing>) which means, for example, that they
1203+
can't begin with a number, nor contain hyphens.
12021204
When different groups within the same pattern have the same name, any reference
12031205
to that name assumes the leftmost defined group. Named groups count in
12041206
absolute and relative numbering, and so can also be referred to by those

0 commit comments

Comments
 (0)