Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixes compilation errors closes #2963
  • Loading branch information
JJ committed Aug 22, 2019
1 parent ca2534f commit a38f5a5
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions doc/Language/regexes.pod6
Expand Up @@ -120,10 +120,12 @@ of a subroutine:
which emphasizes the fact that a L<C<Regex>|/type/Regex> object represents code
rather than data:
&S ~~ Code; # OUTPUT: True
=begin code :preamble<my sub S { /pattern/ }; my regex R { pattern };>
&S ~~ Code; # OUTPUT: True
&R ~~ Code; # OUTPUT: True
&R ~~ Method; # OUTPUT: True (A Regex is really a Method!)
&R ~~ Code; # OUTPUT: True
&R ~~ Method; # OUTPUT: True (A Regex is really a Method!)
=end code
Also unlike with the C<rx> form for defining an anonymous regex, the definition
of a named regex using the C<regex> keyword does not allow for adverbs to be
Expand All @@ -136,11 +138,23 @@ Alternatively, by way of shorthand, it is also possible (and recommended) to use
the C<rule> and C<token> variants of the C<regex> declarator for defining a
C<Regex> when the C<:ratchet> and C<:sigspace> adverbs are of interest:
regex R { :r pattern }; # apply :r (:ratchet) to entire pattern
token R { pattern }; # same thing: 'token' implies ':r'
=for code
regex R { :r pattern }; # apply :r (:ratchet) to entire pattern
and, alternatively
=for code
token R { pattern }; # same thing: 'token' implies ':r'
Or
=for code
regex R { :r :s pattern }; # apply :r (:ratchet) and :s (:sigspace) to pattern
regex R { :r :s pattern }; # apply :r (:ratchet) and :s (:sigspace) to pattern
rule R { pattern }; # same thing: 'rule' implies ':r:s'
with this alternative:
=for code
rule R { pattern }; # same thing: 'rule' implies ':r:s'
Named regexes may be used as building blocks for other regexes, as they are
methods that may called from within other regexes using the C«<regex-name>»
Expand Down Expand Up @@ -185,11 +199,11 @@ I«Smartmatch: "string" ~~ /pattern/, or "string" ~~ /<R>/»
L<Smartmatching|/language/operators#index-entry-smartmatch_operator> a string
against a C<Regex> performs a regex match of the string against the C<Regex>:
say "Go ahead, make my day." ~~ / \w+ /; # OUTPUT: «「Go」␤»
say "Go ahead, make my day." ~~ / \w+ /; # OUTPUT: «「Go」␤»
my regex R { me|you };
say "You talkin' to me?" ~~ / <R> /; # OUTPUT: «「me」␤ R => 「me」␤»
say "May the force be with you. ~~ &R ; # OUTPUT: «「you」␤»
say "You talkin' to me?" ~~ / <R> /; # OUTPUT: «「me」␤ R => 「me」␤»
say "May the force be with you." ~~ &R ; # OUTPUT: «「you」␤»
The different outputs of the last two statements show that these two ways of
smartmatching against a named regex are not identical. The difference arises
Expand Down

0 comments on commit a38f5a5

Please sign in to comment.