The first regex I have will not work, with a filename like: php-gb_0.8.0.tar.gz
This is the code I have.
I have tried to fix it in my own way.
It seems to work, but there must be a more elegant way.
With only one regex.
public function getExt()
{
preg_match("@\.(.+)$@", $this->name, $match);
$case1 = strtolower($match[1]);
preg_match("@\.(tar.gz)$@", $this->name, $match);
$case2 = strtolower($match[1]);
if ($case2)
$this->extension = $case2;
else
$this->extension = $case1;
return $this->extension;
}