Skip to content

Commit 149bb20

Browse files
committed
fix compilation
(don't compile errors; multiple lines separated by ; )
1 parent e8d89a2 commit 149bb20

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

doc/Language/regexes.pod6

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,44 +86,49 @@ be quoted using single or double quotes.
8686
The backslash serves as a switch. It switches a single metacharacter into a
8787
literal, and vice versa:
8888
89-
/ \# / # matches the hash metacharacter literally
90-
/ \w / # turns literal 'w' into a character class (see below)
91-
/Hallelujah\!/ # matches string 'Hallelujah!' incl. exclamation mark
89+
/ \# /; # matches the hash metacharacter literally
90+
/ \w /; # turns literal 'w' into a character class (see below)
91+
/Hallelujah\!/; # matches string 'Hallelujah!' incl. exclamation mark
9292
9393
Even if a metacharacter does not (yet) have a special meaning in Perl 6,
9494
escaping (or quoting) it is required to ensure that the regex compiles and
9595
matches the character literally. This allows the clear distinction between
9696
literals and metacharacters to be maintained:
9797
98-
/ \, / # matches a literal comma ','
99-
/ , / # !! error: a yet meaningless/unrecognized metacharacter
98+
/ \, /; # matches a literal comma ','
99+
100+
=for code :skip-test<deliberate error>
101+
/ , /; # !! error: a yet meaningless/unrecognized metacharacter
100102
# does not automatically match literally
101103
102104
While an escaping backslash exerts its effect on the next individual character,
103105
single I<and multiple> metacharacters may be turned into literally matching
104106
strings by quoting them using single or double quotes:
105107
106-
/ "abc" / # you may quote literals like this, but it has no effect
107-
/ "Hallelujah!" / # yet, this form is generally preferred over /Hallelujah\!/
108+
/ "abc" /; # you may quote literals like this, but it has no effect
109+
/ "Hallelujah!" /; # yet, this form is generally preferred over /Hallelujah\!/
108110
109-
/ "two words" / # quoting a space renders it significant, so this matches
111+
/ "two words" /; # quoting a space renders it significant, so this matches
110112
# the string 'two words' including the intermediate space
111113
112-
/ '#!:@' / # this regex matches the string of metacharacters '#!:@'
114+
/ '#!:@' /; # this regex matches the string of metacharacters '#!:@'
113115
114116
Quoting does not turn every metacharacter into a literal, however. This is due
115117
to the fact that quotes allow for backslash-escapes and interpolation.
116118
Specifically: in single quotes, the backslash may be used to escape single
117119
quotes and the backslash itself; double quotes additionally enable the
118120
interpolation of variables, and of code blocks of the form C<{...}>:
119121
120-
/ '\\\'' / # matches a backslash followed by a single quote: \'
121-
/ '\' / # !! error: this is NOT the way to literally match a
122+
/ '\\\'' /; # matches a backslash followed by a single quote: \'
123+
124+
=for code :skip-test<deliberate error>
125+
/ '\' /; # !! error: this is NOT the way to literally match a
122126
# backslash because now it escapes the second quote
127+
123128
my $x = 'Hi';
124-
/ "$x there!" / # matches the string 'Hi there!'
129+
/ "$x there!" /; # matches the string 'Hi there!'
125130
126-
/ "1 + 1 = {1+1}" / # matches the string '1 + 1 = 2'
131+
/ "1 + 1 = {1+1}" /; # matches the string '1 + 1 = 2'
127132
128133
Strings are searched left to right, so it is enough if only part of the string
129134
matches the regex:

0 commit comments

Comments
 (0)