Skip to content

Commit a38f5a5

Browse files
committed
Fixes compilation errors closes #2963
1 parent ca2534f commit a38f5a5

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

doc/Language/regexes.pod6

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,12 @@ of a subroutine:
120120
which emphasizes the fact that a L<C<Regex>|/type/Regex> object represents code
121121
rather than data:
122122
123-
&S ~~ Code; # OUTPUT: True
123+
=begin code :preamble<my sub S { /pattern/ }; my regex R { pattern };>
124+
&S ~~ Code; # OUTPUT: True
124125
125-
&R ~~ Code; # OUTPUT: True
126-
&R ~~ Method; # OUTPUT: True (A Regex is really a Method!)
126+
&R ~~ Code; # OUTPUT: True
127+
&R ~~ Method; # OUTPUT: True (A Regex is really a Method!)
128+
=end code
127129
128130
Also unlike with the C<rx> form for defining an anonymous regex, the definition
129131
of a named regex using the C<regex> keyword does not allow for adverbs to be
@@ -136,11 +138,23 @@ Alternatively, by way of shorthand, it is also possible (and recommended) to use
136138
the C<rule> and C<token> variants of the C<regex> declarator for defining a
137139
C<Regex> when the C<:ratchet> and C<:sigspace> adverbs are of interest:
138140
139-
regex R { :r pattern }; # apply :r (:ratchet) to entire pattern
140-
token R { pattern }; # same thing: 'token' implies ':r'
141+
=for code
142+
regex R { :r pattern }; # apply :r (:ratchet) to entire pattern
143+
144+
and, alternatively
145+
146+
=for code
147+
token R { pattern }; # same thing: 'token' implies ':r'
148+
149+
Or
150+
151+
=for code
152+
regex R { :r :s pattern }; # apply :r (:ratchet) and :s (:sigspace) to pattern
141153
142-
regex R { :r :s pattern }; # apply :r (:ratchet) and :s (:sigspace) to pattern
143-
rule R { pattern }; # same thing: 'rule' implies ':r:s'
154+
with this alternative:
155+
156+
=for code
157+
rule R { pattern }; # same thing: 'rule' implies ':r:s'
144158
145159
Named regexes may be used as building blocks for other regexes, as they are
146160
methods that may called from within other regexes using the C«<regex-name>»
@@ -185,11 +199,11 @@ I«Smartmatch: "string" ~~ /pattern/, or "string" ~~ /<R>/»
185199
L<Smartmatching|/language/operators#index-entry-smartmatch_operator> a string
186200
against a C<Regex> performs a regex match of the string against the C<Regex>:
187201
188-
say "Go ahead, make my day." ~~ / \w+ /; # OUTPUT: «「Go」␤»
202+
say "Go ahead, make my day." ~~ / \w+ /; # OUTPUT: «「Go」␤»
189203
190204
my regex R { me|you };
191-
say "You talkin' to me?" ~~ / <R> /; # OUTPUT: «「me」␤ R => 「me」␤»
192-
say "May the force be with you. ~~ &R ; # OUTPUT: «「you」␤»
205+
say "You talkin' to me?" ~~ / <R> /; # OUTPUT: «「me」␤ R => 「me」␤»
206+
say "May the force be with you." ~~ &R ; # OUTPUT: «「you」␤»
193207
194208
The different outputs of the last two statements show that these two ways of
195209
smartmatching against a named regex are not identical. The difference arises

0 commit comments

Comments
 (0)