Skip to content

Commit f045213

Browse files
authored
Merge pull request #2923 from threadless-screw/regexes
Minor corrections to regexes section
2 parents b0d5cf9 + d42c110 commit f045213

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

doc/Language/regexes.pod6

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ operators:
4444
$match = m/.+/; say $match; say $match.^name; # OUTPUT: «「abc」␤Match␤»
4545
$match = /.+/; say $match; say $match.^name; # OUTPUT: «/.+/␤Regex␤»
4646
47-
Whitespace in literal regexes is ignored insofar as the L<:sigspace>
48-
adverb|/language/regexes#Sigspace> is not used to make whitespace syntactically
49-
significant.
47+
Whitespace in literal regexes is ignored insofar as the
48+
L<C<:sigspace> adverb|/language/regexes#Sigspace> is not used to make whitespace
49+
syntactically significant.
5050
5151
In addition to whitespace, comments may be used inside of regexes to improve
5252
their readability and comprehensibility just as in Perl6 code in general. This
@@ -261,9 +261,19 @@ Examples of word characters:
261261
262262
=end table
263263
264-
Note that the character classes C«<same>», C«<wb>» and C«<ww>» are
265-
so called zero-width assertions, which do not really match a
266-
character.
264+
The predefined character classes in the leftmost column are all of the form
265+
C«<name>», a hint to the fact that they are implemented as built-in
266+
L<named regexes|/language/regexes#Subrules>.
267+
As such they are subject to the usual capturing semantics. This means that if
268+
a character class is called with the syntax C«<name>» (i.e. as indicated in
269+
the leftmost column), it will not only match, but also capture, installing a
270+
correspondingly named L<named capture|/language/regexes#Named_captures> in the
271+
resulting L<Match object|/type/Match>. In case just a match and no capture is
272+
desired, the capture may be suppressed through the use of call syntax that
273+
includes a leading dot: C«<.name>».
274+
275+
Note that the character classes C«<same>», C«<wb>» and C«<ww>» are so-called
276+
zero-width assertions, which do not really match any character.
267277
268278
=head2 X«Unicode properties|regex,<:property>»
269279
@@ -1250,7 +1260,7 @@ all named captures:
12501260
}
12511261
12521262
A more convenient way to get named captures is by using named regex as discussed in
1253-
the L<Subrules|#Subrules> section.
1263+
the L<Subrules|/language/regexes#Subrules> section.
12541264
12551265
=head2 X«Capture markers: C«<( )>»|regex,<( )>»
12561266

0 commit comments

Comments
 (0)