:g/regexp1 (match lines)/s/oldregexp1/newregexp/

example:
For all lines having hello, replace dog by cat

:g/hello/s/dog/cat/g

To do it for all lines

:g/dog/s//cat/g
