I am attempting to write a regex that will return a multiple line match from a log file. Using the sample below -- I want to match an entire 'transaction' which begins and ends with the same text as ALL other transactions in the log (Start and End). However - between those lines there is a custom identifier -- in this case an email address that will differentiate one transaction from another.
Start of a transaction.
random line 1.
random line 2.
email1@gmail.com
End of a transaction.
Start of a transaction.
random line 1.
random line 2.
email1@yahoo.com
random line 3.
End of a transaction.
Here is what I am starting with:
^Start(.*?)\n(((.*?)(email1\@gmail\.com)(.*?)|(.*?))\n){1,}End (.*?)\n
Essentially - I want to say: Begin with 'Start' -- and match all lines until an 'End' line, but only return a match if one of the lines contains a particular email address.
Right now -- my regex treats the entire log file as a single match since presumably line 1 contains a 'Start' and line X contains an 'End' and somewhere in the hundreds of lines in between -- their is a match for the email. Also -- application is Powershell and will be using a Select-String pattern, if that matters.