How do I replace a capacitor with a resistance?
Okay, you already know that an ideal capacitor is defined in the time domain by the equation

$$i(t) = C\frac{\mathrm{d}v(t)}{\mathrm{d}t}$$

Now you should also know (or at least vaguely remember being taught once and be able to look up) the Fourier transform rule

$$\mathcal{F}\left[\frac{\mathrm{d}}{\mathrm{d}t}x(t)\right]=j\omega{}X(\omega)$$ 
when \$X(\omega)\$ is the transform of \$x(t)\$.

So we can rewrite the capacitor equation in the frequency domain as

$$I(\omega)=Cj\omega{}V(\omega)$$

or

$$\frac{V(\omega)}{I(\omega)}=\frac{1}{j\omega{}C}$$

which is the definition of the impedance of an ideal capacitor, and just what was substituted for the capacitor in your example.