my $text = 'This test creates a [color=blue] blue [/color] word. And a [color=red] red [/color] one'; #### my ($color,@colors); my $new = $text; @colors = $new =~ m/\[color=.*\]/gi; print @colors; #### [color=blue] [color=red]