This would be easy if you did not try to make these text processing tasks "one liners" and just write
the (few lines) code to process the file one line at a time, using any programming language you like.
Basically, if you just processed this text in a loop, reading each line at a time, matching flags and setting patterns, you could have easily processed this file. (Or read the file into an array of lines of text.)
The issue, as I see it, is you (not only you, but many) are falling into the "trap" of looking for "one liners" instead of just writing a small program of a few lines which does the trick.
You are not the only person who falls in to the trap of thinking that everything has to be a "one liner" but this will cause you to waste time when you could write a few lines of code in any programming language and most shell scripts to:
- Read the file into an array of lines.
- Process each line and search for your beginning <VirtualHost tag and set a flag.
- When the flag is set, search and match the other string(s) (SSLInsecureRenegotiation ... blah blah) and put the match(es) in an array.
- Stop processing after the end tag </VirtualHost is matched.
This is only a few lines of code and is very easy for you (or anyone with minimal programming skills) to write and you could have easily written this code in the time it takes to search for a "one liners" to do the job.
I'm not trying to give you a hard time and I like your posts; but I'm just saying. For a guy with nearly 1000 posts here; you should just write a handful of lines of code and process this versus wasting your time searching for the perfect "one-liner" REGEX.
Cheers.