This seems ok: (and never mind deciding on how long the extension
can be):
#!/usr/bin/zsh
filename=$1
extension=${filename:e}
# just in case there's a trailing dot: don't remove in unless there
is an extension.
[ "$extension" ] && filename="${filename%.*}"
echo filename is: $filename
echo extension is: .$extension # I'll keep the dot on the extension.
If the input is "foo.", this script will print "filename is: foo." (note the trailing dot). Probably not what you want. If you use :r instead, you'll get the expected "foo" without the trailing dot.
Roman