The formation of beams of triatomic deuterium D3 and the mixed isotopic molecule D2H was optically observed for the first time when the corresponding ions were neutralized by charge exchange. The molecules were detected via the transitions between the Rydberg states n=3 and n=2. An assignment of the D2H spectrum is given. The total lifetimes of rotational sublevels of different electronic states with n=3 of D3 were measured from the radiative decay of molecules along their path behind the charge-exchange region. Agreement with theory is satisfactory.