I am looking for regex pattern where it will search string only if another string matches in previous few lines, for e.g.
abc----1
pqr----2
123----3
xyz----4
lll----5
pqr----6
123----7
qqq----8
so here say I want to find 123 only if we go above and first find xyz and not abc. So outout should be only matching pattern is line no 7 and not 3. Thanks, Tim for an answer, One more additional criteria are I wanted to replace 123 only not all line found by this pattern