in reply to Problem with RegEx & various "endings"

I wouldn't try to fit everything into one regexp, try creating a series of regexes like:
my $group; if ($teststring =~ /^\[(\w+)]/) { $group = $1; } elsif ($teststring =~ /^(\w+)/ { $group = $1; ...
(the r.e.s may not be perfect, i'm just writing them without testing)