Hi, @mark-boonie,
Hum, I’m a bit upset with the example that you provided !
Indeed, I’ve already find out a regex solution, following exactly what you said in your initial post
So, I created this sample of text below :
bla bla
<start string>
blo blo
<target string>
<end string>
bla bal
blah blah
<start string>
<end string>
<start string>
<target string>
blu blu
<end string>
bla bla
<start string>
bla bla
blah blah
<end string>
bla bla
<start string>
<target string>
<end string>
bla bla
Now :
Open the Replace dialog ( Ctrl + H )
Uncheck any box option
Find (?s)^<start string>((?!<start string>).)+?<target string>.+?^<end string>\R(*SKIP)(*F)|(?-s)^.*\R
Replace Leave EMPTY
Check the Wrap around option
Select the Regular expression search mode
Click on the Replace All button
=> You should be left with this text :
<start string>
blo blo
<target string>
<end string>
<start string>
<target string>
blu blu
<end string>
<start string>
<target string>
<end string>
You can verify that, in this OUTPUT :
Any text outside the blocks <start string>....<end string> have been deleted
Text within blocks <start string>....<end string> which do not contain the line <target string> have been deleted, too
It just remains blocks starting with a <start string> line and ending with a <end string> line which do contain a line <target string>
And note that, in this last case, all the lines of these blocks are kept, too !
However, with the text provided :
The delimiters *Block start and *Block end are different than in your initial post, but this is not a problem
But the fact that the <target string> cannot be clearly identify is a BIG problem
Indeed, from your example, how may I know that this block of text must be kept or not ??
I probably miss something …
BR
guy038