my $string = "AAACANANANTANAACATNNCAAAAAA"; my @matches = $string =~ /([AN]+)/g; $\=$,=$/; print @matches; __DATA__ output: AAA ANANAN ANAA A NN AAAAAA