Ah! Yes, looked at that way, of course it is intuitive. I'm thinking 'grab the match' not 'remove what doesn't match' ... and frankly I know better. I get so rusty.First, think about the way the `#` and `%` operators work: they _remove_ matching strings from the parameter value when expanding it. So if there is no matching string, they don't remove anything. That seems completely intuitive; it would be weird for it to remove _everything_ when there's no match.
Looks good, but that grabs the longest match and I want the shortest.
If your goal is to extract the extension if there is one, you might be better served by a regex match.
[[ $filename =~ '\.(.*)' ]]
extension=$match[1]
That way, $extension be empty if there's no extension.