my $regex="a (.*) a(.)*"; $str =~ m/ $regex(?{push @substrings, $^N}) (?!) /x;