Skip to content

Commit 90da8ef

Browse files
author
Jan-Olof Hendig
committed
Added some examples to .prematch and .postmatch
1 parent 8858b54 commit 90da8ef

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

doc/Type/Match.pod6

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,34 @@ Returns a hash of named submatches.
6868
6969
=head2 method prematch
7070
71+
Defined as:
72+
73+
method prematch(Match:D:) returns Str:D
74+
7175
Returns the part of the original string leading up to the match.
7276
77+
'abcdefg' ~~ /cd/;
78+
say $/.prematch; # ab
79+
80+
# will return a list of three match objects
81+
"abc123def" ~~ m:g/\d/;
82+
say $/.[1].prematch; # abc1
83+
7384
=head2 method postmatch
7485
86+
Defined as:
87+
88+
method postmatch(Match:D:) returns Str:D
89+
7590
Returns the part of the original string following the match.
7691
92+
'abcdefg' ~~ /cd/;
93+
say $/.postmatch; # efg
94+
95+
# will return a list of three match objects
96+
"abc123def" ~~ m:g/\d/;
97+
say $/.[1].postmatch; # 3def
98+
7799
=head2 method make
78100
79101
method make(Match:D: Mu $ast)

0 commit comments

Comments
 (0)