How do astronomers use spectral analysis to determine if a distant galaxy is moving away from us?

Answer

By observing that the entire pattern of spectral lines is shifted toward the red end of the spectrum (redshift).

If the entire pattern of spectral lines is shifted toward the red end (redshift), it indicates the star or galaxy is moving away due to the Doppler effect, which is key for cosmology.

How do astronomers use spectral analysis to determine if a distant galaxy is moving away from us?
spectrometerlightinstrumentpurposeanalysis