mirror of
https://github.com/XAMPPRocky/tokei
synced 2024-10-30 07:11:48 +00:00
24 lines
547 B
Raku
24 lines
547 B
Raku
# 24 lines 14 code 8 comments 2 blanks
|
|
=begin
|
|
Regex methods and functions
|
|
=end
|
|
|
|
=begin item match
|
|
Match C<$text> against C<$regex>. If the C<$global> flag is
|
|
given, then return an array of all non-overlapping matches.
|
|
=end item
|
|
|
|
sub match ($text, $regex, :$global?) {
|
|
my $match := $text ~~ $regex;
|
|
if $global {
|
|
my @matches;
|
|
while $match {
|
|
nqp::push(@matches, $match);
|
|
$match := $match.parse($text, :rule($regex), :c($match.to));
|
|
}
|
|
@matches;
|
|
}
|
|
else {
|
|
$match;
|
|
}
|
|
}
|