Use File.extname instead of regular expression