Skip to content

Commit 09867b7

Browse files
committed
Regexes: document :overlap and :exhaustive
1 parent 8c92426 commit 09867b7

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

lib/Language/regexes.pod

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,30 @@ the start of the string, but C<:c> overrides that.
826826
827827
=head3 Exhaustive
828828
829-
TODO
829+
To find all possible matches of a regex, including overlapping ones, and
830+
several ones that start at the same position, supply the C<:exhaustive> (short
831+
C<:ex>) adverb.
832+
833+
given 'abracadabra' {
834+
for m:exhaustive/ a .* a / -> $match {
835+
say ' ' x $match.from, ~$match;
836+
}
837+
}
838+
839+
Produces this output:
840+
841+
=begin code
842+
abracadabra
843+
abracada
844+
abraca
845+
abra
846+
acadabra
847+
acada
848+
aca
849+
adabra
850+
ada
851+
abra
852+
=end code
830853
831854
=head3 X<Global|regex adverb,:global;regex adverb,:g>
832855
@@ -855,7 +878,19 @@ C<:p> is a shortcut for C<:pos>.
855878
856879
=head3 Overlap
857880
858-
TODO
881+
To get several matches, including overlapping matches, but only one (the
882+
longest) from each starting position, specify the C<:overlap> (short C<:ov>)
883+
adverb:
884+
885+
given 'abracadabra' {
886+
for m:overlap/ a .* a / -> $match {
887+
say ' ' x $match.from, ~$match;
888+
}
889+
}
890+
891+
produces
892+
893+
=begin code
859894
860895
=head1 Best Practices and Gotchas
861896

0 commit comments

Comments
 (0)