$astr=@("Event", "\*\*\*\*", "--------")
#Gets them all
#set up the regexp
$regex = '(?ms) Event waited on(.+?)\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*'
#get-content gets an array of strings, join them all into one string separated by newline
$string=(Get-Content .\CCI1_ora_15824_2.txt) -join "`n"
# search for the regexp in the string and output the matches
Select-String -input $string -Pattern $regex -AllMatches | `
% { $_.Matches } | `
% {
$arr = $_.Value -split "`n"
foreach ($line in $arr) {
# output only lines that do not contain the strings in the array, trim it and replace "more than one space" with a semi-colon
Select-String -input $line -pattern $astr -NotMatch | ForEach-Object {$_.Line.Trim() -replace ' +',";"}
}
}