syslog - Conditional Regex, how to extract a subset of a match? -
i have syslog strings, this:
lwiod[2469]: s-1-5-21-2071757552-4033313730-2397045981-3628|0xc94f000|logon|status_success|10.10.19.10|10.10.42.40|company\username lwiod[2469]: s-1-5-21-2071757552-4033313730-2397045981-3628|0xc94f000|logon|status_success|10.10.19.10|10.10.42.40|username@company lwiod[2469]: s-1-5-21-2071757552-4033313730-2397045981-3628|0xc94f000|logon|status_success|10.10.19.10|10.10.42.40|unknown and have regexp capture need, this:
lwiod\[([0-9]+)\]: (.*)\|(.*)\|logon\|status_(.*)\|(.*)\|(.*)\|(company\\.*|.*\@company|unknown) what need regexp give me username or unknown in field 7 only, don't want company (which ad domain name), i'm having trouble.
field 1 s-1-5-21-2071757552-4033313730-2397045981-3628, 2 0xc94f000, ... , 7 username or unknown.
thanks!
okay, guess use this?
lwiod\[([0-9]+)\]: (.*)\|(.*)\|logon\|status_(.*)\|(.*)\|(.*)\|(?:company\\)?(unknown|[^@]+)(?:@)?
from current regex, appears company is, assumed same. otherwise, guess can use
lwiod\[([0-9]+)\]: (.*)\|(.*)\|logon\|status_(.*)\|(.*)\|(.*)\|(?:[^\\]*\\)?(unknown|[^@]+)(?:@)?
Comments
Post a Comment