There are a couple of typos but it seems to work logically exactly as specified, I've added comments to clarify:
Code:
...
#kbp: make STR an empty string
STR=""
STARTPOINT=0
while [[ ${NUMBEROFGROUPS} -gt 0 ]]; do # {
CURRENTGROUP=${NUM:${STARTPOINT}:3}
D1=${CURRENTGROUP:0:1}
D2=${CURRENTGROUP:1:1}
D3=${CURRENTGROUP:2:1}
#kbp: if the number entered has a leading zero...
if [[ ${D1} -eq 0 ]]; then # {
#kbp: .. and if the second digit is a zero and the the third digit isn't ...
if [[ ${D2} -eq 0 ]] && [[ ${D3} -ne 0 ]]; then
#kbp: ... set STR
STR="${STR} ${ARRAY1[D3]} ${ARRAY4[NUMBEROFGROUPS]}"
fi
fi
echo "${D1} ${D2} $D3"
STR will only be set to a non-empty string if the number entered is in the format: 00[1-9] .. is this what you wanted?