Skip to content

Commit

Permalink
Regexes: document :overlap and :exhaustive
Browse files Browse the repository at this point in the history
  • Loading branch information
moritz committed Jan 27, 2015
1 parent 8c92426 commit 09867b7
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions lib/Language/regexes.pod
Expand Up @@ -826,7 +826,30 @@ the start of the string, but C<:c> overrides that.
=head3 Exhaustive
TODO
To find all possible matches of a regex, including overlapping ones, and
several ones that start at the same position, supply the C<:exhaustive> (short
C<:ex>) adverb.
given 'abracadabra' {
for m:exhaustive/ a .* a / -> $match {
say ' ' x $match.from, ~$match;
}
}
Produces this output:
=begin code
abracadabra
abracada
abraca
abra
acadabra
acada
aca
adabra
ada
abra
=end code
=head3 X<Global|regex adverb,:global;regex adverb,:g>
Expand Down Expand Up @@ -855,7 +878,19 @@ C<:p> is a shortcut for C<:pos>.
=head3 Overlap
TODO
To get several matches, including overlapping matches, but only one (the
longest) from each starting position, specify the C<:overlap> (short C<:ov>)
adverb:
given 'abracadabra' {
for m:overlap/ a .* a / -> $match {
say ' ' x $match.from, ~$match;
}
}
produces
=begin code
=head1 Best Practices and Gotchas
Expand Down

0 comments on commit 09867b7

Please sign in to comment.