Skip to content

Commit 30b231c

Browse files
committed
Merge pull request #200 from ungrim97/feature/nested_named_captures
Document how to create nested named captures without subrules
2 parents 9d1ef4e + 6ee2200 commit 30b231c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

doc/Language/regexes.pod

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,13 @@ and slightly verbose -- way of naming captures is like this:
604604
The access to the named capture, C<< $<myname> >>, is a shorthand for indexing
605605
the match object as a hash, in other words: C<$/{ 'myname' }> or C<< $/<myname> >>.
606606
607+
Named captures can also be nested using regular capture group syntax:
608+
609+
if 'abc-abc-abc' ~~ / $<string>=( [ $<part>=[abc] ]* % '-' ) / {
610+
say ~$<string> # abc-abc-abc
611+
say ~$<string><part> # [abc, abc, abc]
612+
}
613+
607614
Coercing the match object to a hash gives you easy programmatic access to
608615
all named captures:
609616

0 commit comments

Comments
 (0)