Michael Wilde replied to Nikita's discussion Count failures and success via transaction
Nikita posted a discussionI am trying to pull out the hostname of a virus scan message and create a new field, but I am not having any luck. This is the part of the log I am trying to run a regex against:
virus detected in \HOST001\SERVER-AV-1\
I can't seem to get what is between the first \ and second \
Any help would be appreciated
Tags:
Permalink Reply by Michael Wilde on October 3, 2011 at 9:22pm Perry... think it out... talk it out.. like this..
a backslash, ( followed by any character that is not a backslash ), followed by a backslash.
I put the parens around the phrase above, because we'll use that as a capturing group.
--for the backslashes we'll need to "escape them" -- you do that by adding an extra backslash, that tells the engine to treat this next character literally... then the parens tell us "we're going to capture the stuff in the parens so we can refer to it. The first capturing group is known as $1. Next.. see those brackets with a "carat" in them. Thats a list of characters that our match cannot possibly be--but repeated between 1 and unlimited times with that "+" at the end. Close the parens, sealing off our capturing group, and then follow it with an escaped backslash and you should be goo.
REGEX = \\([^\\]+)\\
© 2012 Created by Michael Wilde.
