$foo="rd_repower_g_01.txt.gz_20040624-10.03"; $foo=~ s/^(rd_[a-z\d]+).*$/$1/; print "$foo\n";