I have an XML file where I would to select blocks if and only if they contain a certain value:
<outer block>
<name>A</name>
<inner block>Hello</inner block>
</outer block>
<outer block>
<name>B</name>
<inner block>Hello again</inner block>
</outer block>
<outer block>
<name>C</name>
<inner block>Goodbye</inner block>
</outer block>
<outer block>
<name><D</name>
<inner block>Goodbye</inner block>
</outer block>
Notepad++ can query over multiple lines so I can treat this as a single line.
I would like to select the two blocks with Goodbye so that the matched strings appear as:
<outer block>
<name><C</name>
<inner block>Goodbye</inner block>
</outer block>
<outer block>
<name><D</name>
<inner block>Goodbye</inner block>
</outer block>
I have got the following expression
<outer block>(.*?)Goodbye(.*?)</outer block>
, but it gives me the first all the way to the end of the first </outer block> after Goodbye.
Matched string 1
<outer block>
<name>A</name>
<inner block>Hello</inner block>
</outer block>
<outer block>
<name>B</name>
<inner block>Hello again</inner block>
</outer block>
<outer block>
<name>C</name>
<inner block>Goodbye</inner block>
</outer block>
and Matched string 2
<outer block>
<name><D</name>
<inner block>Goodbye</inner block>
</outer block>
Ideally, I would get an output for C that is the same as D..*
I have tried lookaheads but Notepad does not accept them as valid expressions. Below is what I would expect the expression to look like.
<outer block>(.anything but another 'outer')Goodbye(.anything but another 'outer')</outer block>
Regex101.com does not use the particular flavour of Regex that Notepad uses so I’m at a loss.