Disclaimer:
- I know to read in text files with the
-raw
switch - I know about the
(?sm)
and-AllMatches
qualifiers - I've read the other similar solutions (Multiline regex to match config block and REGEX for multiple lines - powershell) but can't successfully modify their solutions for my use case
I have a log file ~1200 lines long, so not overly huge. The log file is a mixture of 'plain text' and then that 'plain text' is repeated as XML. I want to select (and ultimately remove) the blocks of 'plain text' so the blocks of XML remain.
The plain text blocks start with Log Name:
then some more text on that line, then multiple lines with text, finishing with Event Xml:
(nothing else on this line).
Example plain text block:
Log Name: AD FS Tracing/Debug
(multiple lines of text)
Event Xml:
My attempts either select nothing, or everything, or eveything from the first Log Name:
to the last Event Xml:
Example regex pattern:
'(?smi)Log Name:.*Event Xml:'
Have tried this in powershell and notepad++. The log files are from Event Viewer on Windows 2012R2, so alternative solution to solve my overall issue: How to you export just the XML
from Event Viewer?
Edit: (@ https://stackoverflow.com/users/3832970/wiktor-stribi%c5%bcew)
'(?si)Log Name:.*?Event Xml:'
selects the entire log file. I had tried modifying the similar questions, but it doesn't select what I want. Hence why I asked my specific question - it's not a duplicate.