I am struggling write a RegEx to extract many blocks (with start and end delimiters) from a large logfile, but only where a certain string is in the block. I want the RegEx to run in the VSCode Find tool so I can copy the matching blocks into a new file.
Example data
begin
stuff
end
begin
this is thing
end
begin
others
end
begin
also thing
end
begin
other stuff
end
I want to write a regular expression to extract a list only blocks that contain the string "thing".
Desired output
begin
this is thing
end
begin
also thing
end
The RegEx I have so far is
begin[\s\S\r]+?end
The above is splitting the log file up into blocks, but I can't figure out how to selectively return only blocks containing the string "thing".