yadda yadda start this is comment start this is still comment end this should still be comment end yadda yadda
####
this is comment start this is still comment
##
##
sub between {
my ($text) = @_;
my $level = 0;
my @comments = ();
while ( $text =~ m{\G .*? (start|end) (.*?) (?: (?=start|end) | $ ) }gxs ) {
if ( $1 eq 'start') { $level++; }
else { ($level > 0) and $level--; }
$level > 0 and push(@comments, $2);
}
return join('', @comments);
}
##
##
this is comment this is still comment this should still be comment