We have a logging application which produces well formatted output for systems known to it (CSV); otherwise it provides a long string of data into a generic "message" field in the CSV.
I have 6 regular expression patterns which pulls the specific data I want out of generic message field to put into my custom formatted CSV.
$REGEX1 = 'pattern1'
$REGEX2 = 'pattern2'
$DATA | % {
$_.message -match $REGEX1
$_.message -match $REGEX2
..
}
I'm evaluating each CSV line 6 times- is there a more efficient way to do this?