Skip to content

Commit

Permalink
Adds doc for $¢ closes #1760
Browse files Browse the repository at this point in the history
  • Loading branch information
JJ committed Jul 25, 2018
1 parent 69be66c commit b94f678
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions doc/Type/Match.pod6
Expand Up @@ -13,6 +13,20 @@ in the original string, and a payload referred to as I<AST> (abstract syntax
tree), which can be used to build data structures from complex regexes and
grammars.
The last match is also stored in the X<C<>> variable:
my $c;
'abc' ~~ /.$${ $c = $¢ }/;
say $c; # OUTPUT: «「c」␤»
In this case, we are running the code among curly braces when the match occurs,
in this case the last letter in the string; C<$c> gets the value of the cursor
C<>, which contains the C<Match>. This C<> offers a way of capturing the Match inside a regular expression; if you are not going to use it inside that you can simply use L<C<$/>|/syntax/$$SOLIDUS>
my $c; 'camelia' ~~ /<[ l m ]> {$c = $¢}/;
say $c; # OUTPUT: «「m」␤»
say $/; # OUTPUT: «「m」␤»
Submatches are also C<Match> objects (or lists of C<Match> objects,
if the corresponding regex was quantified), so each match object
can be seen as the root of a tree of match objects.
Expand Down

0 comments on commit b94f678

Please sign in to comment.