Skip to content

Commit

Permalink
- Added the Regex::Matches.join() method which joins together the cap…
Browse files Browse the repository at this point in the history
…tures.

Example:
	var match = "abc".match(/(.)(.)(.)/);
	say match.join("-");	# prints: 'a-b-c'
  • Loading branch information
trizen committed Sep 7, 2015
1 parent 1428ebc commit 087c773
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/Sidef/Types/Regex/Matches.pm
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ package Sidef::Types::Regex::Matches {
*ncap = \&named_captures;
*ncaps = \&named_captures;

sub join {
my ($self, $sep) = @_;
Sidef::Types::String::String->new(join($sep->get_value, @{$self->{captures}}));
}

sub to_s {
my ($self) = @_;
Sidef::Types::String::String->new(join(' ', @{$self->{captures}}));
Expand Down

0 comments on commit 087c773

Please sign in to comment.