Say I have a text containing the words red and blue.
How do I replace occurences of the word blue with the word green only in all lines containing the word red?
Likewise how can I replace blue with green in all lines NOT containing the word red?