Splunk Search

Rex not working for special characters

jravida
Communicator

Hi Folks,

I've worked out a regex to pull out group names from audit logs. It works for one field with no special characters, but in another, more elaborated field, my rex becomes confused.
Example

|rex "\w+ added to (?"EXTRACTION SHOULD BE HERE BUT SPLUNK.com FILTERS THE TAGS"\w+) in the \w+"

"Member Bill added to Mail Admin in the Restricted Groups Policy PostOffice"

works fine, but when it becomes more complex I am not sure how to have the rex query ignore all the special characters that may show up

"Member Bill added to Mail Admin in the Restricted Groups Policy (SLASHES)K12\\DC5000Dallas [WEDT] Mail Admin"

This turns up nothing. So basically I want to eliminate the slashes (that don't show up here oddly) and [] that get mixed in, just ignore after the group name extraction. Thanks in advance!

Edit, splunk filters out the tags so the rex looks weird but I'm using the correct named extration

Tags (2)
1 Solution

somesoni2
Revered Legend

Try this

|rex "(\w+\s)+added to (?<myField>.*) in the"

View solution in original post

somesoni2
Revered Legend

Try this

|rex "(\w+\s)+added to (?<myField>.*) in the"

ppablo
Retired

There's a reason @somesoni2 is always the #1 or #2 ranked user on Answers 😜

0 Karma

sk314
Builder

that was fast! didn't see it before I posted a somewhat similar regex!!

0 Karma

jravida
Communicator

Thanks for the fast response! I was a bit more off than I though!

0 Karma

jravida
Communicator

I just want to pull out "Mail Admin" and discard the rest

0 Karma

sk314
Builder

could you specify what would be the correct extraction in the last example (the one with [WEDT])?

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...