zsh 変数代入による拡張子削除などの書き方

# variable substitution
somevar="bu&^*ck" # variable with mucky characters
print ${somevar//[^[:alnum:]]/_} # replace all non-alphanumerics with _
echo ${file##*/} # echo just the file name
echo ${texfilepath%/*.*} # echo just the path
echo ${file%.*} # strip file extension
echo $file:r # strip file extension
echo ${0##*[!0-9]} # strip all but trailing digit from filename $0
echo ${(M)0%%<->} # strip all but trailing digit from filename
file=${1/\//C:\/} # substitute / with c:/ ANYWHERE in string
file=${1/#\//C:\/} # substitute / with c:/ Beginning of string
file=${1/%\//C:\/} # substitute / with c:/ End of string
# note # & % are using to match beginning and end