# non-greedy dot-star @colors = $new =~ m/(\[color=.*?\])/gi; # say what you mean: match non-] characters @colors = $new =~ m/(\[color=[^\]]*\])/gi;