I'm trying to parse some Microsoft logging information. The logs come as big blobs of supposedly "human readable" text, examples of which can be seen at the Windows Security Blog, and there is a specific event that I want to exclude from my analysis, namely "An operation was performed on an object" when the object in question is a groupPolicyContainer.
Here's my regular expression and test code:
my $re = qr/(?ms)EventCode=(4662)[^\d].*Object Type:\s*((?!groupPolicyContainer)\S)*/;
if ($sample1 =~ $re) { print "Matches -- should not have\n"; }
if ($sample2 =~ $re) { print "Matches -- and should have!\n"; }
$sample1
contains the phrase Object Type: groupPolicyContainer
and $sample2
contains the phrase Object Type: Key
. (They both have the same EventCode; this is a contrived test case.) If you look at the link, you can see that there's a lot of text surrounding the two key phrases, "EventCode" and "Object Type". "Object Type" does not occur more than once per log entry (in my contrived test case).
The regular expression says: both match. My expectation is that the first should not match, since it contains the negated phrase! I attempted to implement the code shown in a previous Stack Overflow response, and it doesn't seem to be working; the only difference between that example and mine is that mine operates on a multi-line document.
I've tried every possible combination of (?ms)
I could think of! Is there something special I have to do to make this work in a multi-line document?