Created
February 20, 2012 13:22
-
-
Save moritz/1869161 to your computer and use it in GitHub Desktop.
Exhaustive regex matching
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub ex($str, &re) { | |
gather { | |
my $m := $str.match(&re); | |
if $m { | |
take $m; | |
take $m while $m := $m.CURSOR.'!cursor_next'().MATCH; | |
} | |
} | |
} | |
say ' ' x .from, .Str for ex('abracadabbra', rx/a.+a/); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abracadabbra | |
abracada | |
abraca | |
abra | |
acadabbra | |
acada | |
aca | |
adabbra | |
ada | |
abbra |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment