Know this has been addressed before, but cannot find it. Need to find all lines containing XXX and IFF those lines contain YYY replace YYY with ZZZ. Must be SOME way to do it other than one at a time.
1/ Serch for ^(.?XXX)
Replace with @\1 (or anything that won't possibly occur in your text)
2/ Search for ^(@.?)YYY
Replace with \1ZZZ
2a/ Repeat 2/ if some lines have more than 1 instance of YYY
3/ Search for ^@
Replace with nothing.
What this does is to:
1/ Mark all lines that have XXX with a leading marker (I chose @)
2/ Locate YYY in lines with the leading marker and change them. Repeat until all occurrences are changed
3/ Remove marker