in reply to why this regular expression is so slow?

I assume you want $1, $2, $3 and $4 to be something other than "." and "-". If so, how about:
perl -le' $_ = "..."; s/[\.-]+//g; if (/(\S)(\S)(\S)(\S)$/) { print "$1$2$3$4" } '

or just

perl -le' $_ = "..."; s/[\.-]+//g; print substr $_, -4; '