$_ = 'abcd_efgh-1.2.3-hjik-3.4.5.tar.gz'; print $1 if /(.+?)-[a-z].+?/i; ## prints abcd_efgh-1.2.3