Skip to content

Commit 4bff7ff

Browse files
committed
Small revision for #2887
1 parent f860bf5 commit 4bff7ff

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

doc/Language/regexes.pod6

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ matching those patterns to actual text.
1313
1414
=head1 X<Lexical conventions|quote,/ /;quote,rx;quote,m>
1515
16-
Perl 6 has special syntax for writing regexes:
16+
Perl 6 has special syntax for literal regexes:
1717
1818
m/abc/; # a regex that is immediately matched against $_
1919
rx/abc/; # a Regex object; allow adverbs to be used before regex
@@ -22,7 +22,7 @@ Perl 6 has special syntax for writing regexes:
2222
For the first two examples, delimiters other than the slash can be used:
2323
2424
m{abc};
25-
rx{abc};
25+
rx[abc];
2626
2727
Note that neither the colon nor round parentheses can be delimiters; the colon
2828
is forbidden because it clashes with adverbs, such as C<rx:i/abc/>
@@ -36,13 +36,17 @@ Example of difference between C<m/ /> and C</ /> operators:
3636
$match = m/.+/; say $match; say $match.^name; # OUTPUT: «「abc」␤Match␤»
3737
$match = /.+/; say $match; say $match.^name; # OUTPUT: «/.+/␤Regex␤»
3838
39-
Whitespace in regexes is generally ignored (except with the C<:s> or,
39+
Whitespace in literal regexes is generally ignored (except with the C<:s> or,
4040
completely, C<:sigspace> adverb).
4141
4242
Comments work within a regular expression:
4343
4444
/ word #`(match lexical "word") /
4545
46+
as long as the syntax for
47+
[embedded comments](/language/syntax#Multi-line_/_embedded_comments), with a
48+
backtick and enclosing braces, is usesd.
49+
4650
=head1 Literals
4751
4852
The simplest case for a regex is a match against a string literal:
@@ -57,7 +61,7 @@ to match a colon), or be within quotes:
5761
5862
/ 'two words' /; # matches 'two words' including the blank
5963
/ "a:b" /; # matches 'a:b' including the colon
60-
/ '#' /; # matches a hash character
64+
/ \# /; # matches a hash character
6165
6266
Strings are searched left to right, so it is enough if only part of the string
6367
matches the regex:
@@ -70,8 +74,8 @@ matches the regex:
7074
say $/.to; # OUTPUT: «22␤»
7175
};
7276
73-
Match results are stored in the C<$/> variable and are also returned from
74-
the match. The result is of type L<Match|/type/Match> if the match was
77+
Match results are always stored in the C<$/> variable and are also returned from
78+
the match. They are both of type L<Match|/type/Match> if the match was
7579
successful; otherwise it is L<Nil|/type/Nil>.
7680
7781

0 commit comments

Comments
 (0)