We develop a formula for matching a Taylor series about the origin and an asymptotic exponential expansion for large values of the coordinate. We test it on the expansion of the generating functions for the moments and connected moments of the Hamiltonian operator. In the former case the formula produces the energies and overlaps for the Rayleigh-Ritz method in the Krylov space. We choose the harmonic oscillator and a strongly anharmonic oscillator as illustrative examples for numerical test. Our results reveal some features of the connected-moments expansion that were overlooked in earlier studies and applications of the approach.