my $string = ' Costly false alarms Mindless yobs terrorise OAPs Road deaths Twisted porn pervert caged for life Greenbelt homes plan appeal thrown out '; my @matches = $string =~ m!(]*>)(.+?]*>)!ig; print "$_\n" foreach @matches; #### my %matches = $string =~ m!(]*>)(.+?]*>)!ig; foreach my $key (keys %matches) { print "$key\n"; print "$matches{$key}\n\n"; }