Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
implement :g in .match
  • Loading branch information
moritz committed Jan 4, 2010
1 parent e06af48 commit 52d140e
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/core/Any-str.pm
Expand Up @@ -131,8 +131,20 @@ augment class Any {
self gt '' ?? self.substr(0,1).lc ~ self.substr(1) !! ""
}

our multi method match(Regex $pat, :$c = 0) {
Regex::Cursor.parse(self, :rule($pat), :c($c));
our multi method match(Regex $pat, :$c = 0, :$g) {
if $g {
my $cont = $c;
gather while my $m = Regex::Cursor.parse(self, :rule($pat), :c($cont)) {
take $m;
if $m.to == $m.from {
$cont = $m.to + 1;
} else {
$cont = $m.to;
}
}
} else {
Regex::Cursor.parse(self, :rule($pat), :c($c));
}
}

our multi method ord() {
Expand Down

0 comments on commit 52d140e

Please sign in to comment.