Near-resonant charge transfer in collisions of rare-gas ions with simple molecules within the energy range 4-45 keV