push @array, $1 while $str =~ /(?^(\w+)|\[(\w+)\])/g;