in reply to Re: Re: Drop middle part in a substitution
in thread Drop middle part in a substitution

Not to be picky but you are aware that newlines are valid in filenames under some OS's, right? :)

If the filename ends with a newline, you'll end up keeping the last 4 characters instead of the last three. Try:

s/^(.*\.).*(...)\z/$1$2/s;
instead.