How do you untar multiple files into multiple subdirectory based on filename

With GNU tar and its s command with syntax from sed. I switched from s/// to s|||.

tar -xvf file.tar --transform 's|\(....\).*|\1/&|' --show-transformed-names