-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
In Introduction to Perl 6 Regex, in the section titled matching Perl variables, it looks like the syntax for Regex named captures has changed from:
$<foo>:=[ ]
to:
$<foo>=[ ]
$ perl6 -v
This is Rakudo version 2016.11 built on MoarVM version 2016.11
implementing Perl 6.c.
$ cat 3.pl
# vim: filetype=perl6
'ABC123' ~~ / $<foo>:=[ <[A..Z]+[0..9]>**4 ] /;
say $/<foo>;
$ perl6 3.pl
===SORRY!===
Unrecognized regex metacharacter = (must be quoted to match literally)
at /Users/7stud/p6_programs/3.pl:4
------> 'ABC123' ~~ / $<foo>:⏏=[ <[A..Z]+[0..9]>**4 ] /;
Unable to parse regex; couldn't find final '/'
at /Users/7stud/p6_programs/3.pl:4
------> 'ABC123' ~~ / $<foo>:=⏏[ <[A..Z]+[0..9]>**4 ] /;
And after changing :=
to =
:
$ cat 4.pl
# vim: filetype=perl6
'ABC123' ~~ / $<foo>=[ <[A..Z]+[0..9]>**4 ] /;
say $/<foo>;
~/p6_programs$ perl6 4.pl
「ABC1」
I was initially confused by the named capture example anyway because it wasn't clear what the syntax for a named capture actually was. perl6 has so much strange punctuation that I thought the :=
was some sort of perl6 regex kung fu rather than the syntax for named captures, so an example of the syntax without a regex cluttering things up would have been clearer, e.g. "Named captures use the following syntax:
$<foo>=[ regex here ]
Metadata
Metadata
Assignees
Labels
No labels