with bash variables, you can do this:
DOMAINNAME=abcdef
CHAR2=${DOMAINNAME:1:1}
CHAR4=${DOMAINNAME:3:1}
echo "char2=$CHAR2, char4=$CHAR4"
gives:
char2=b, char4=d
explanation
the meaning of this: ${DOMAINNAME:3:1}
means: take substring starting from the character at pos 3 (0-based, so the 4th character), and length = 1 character.