while ($test =~ m!\[img\]([^\[]+)\[\/img\]!g) { print "$1 \n"; }