Splunk Search

Need to understand the following expression.

Nicksyboy
Explorer

I recently came across a Splunk expression, as

rex "(?i)\".*? (?P/\w+/((\w+\.\d+)|(\w+\d+))/((\w+/)|(\w+/\w+/)|((\w+/\w+/\w+/)))\D+((\?)|(\s)))\w+"

and due to the usage of toom many forward and backward slash, I am unable to understand it. Can you please help me in the matter?

Tags (1)
0 Karma
1 Solution

gelica
Communicator

I like this site alot for checking regexes: http://www.regexper.com/

The regex needed a little modification, but only escaping "/"
This is the regex I ran to get the site to work:

.*? (\/\w+\/((\w+\.\d+)|(\w+\d+))\/((\w+\/)|(\w+\/\w+\/)|((\w+\/\w+\/\w+\/)))\D+((\?)|(\s)))\w+

View solution in original post

gelica
Communicator

I like this site alot for checking regexes: http://www.regexper.com/

The regex needed a little modification, but only escaping "/"
This is the regex I ran to get the site to work:

.*? (\/\w+\/((\w+\.\d+)|(\w+\d+))\/((\w+\/)|(\w+\/\w+\/)|((\w+\/\w+\/\w+\/)))\D+((\?)|(\s)))\w+

lukejadamec
Super Champion

Pull a fieldname that is followed by a / then one or more letters followed by a /, which will be followed by one of the following:

one or more letters followed by a . followed by one or more digits, or

one or more letters followed by one or more digits.

This will be followed by a / and then one of the following:

One or more letters, or

One or more letters followed by a / then one or more letters followed by a /, or

One or more letters followed by a / then one or more letters followed by a / then one or more letters followed by a /

This will be followed by one or more Non-digits.

I think that covers all of the /shs.

lukejadamec
Super Champion

You should accept the answer so others know the issue is closed.

0 Karma

lukejadamec
Super Champion

You are welcome.

0 Karma

Nicksyboy
Explorer

Thanks guys for your quick response!

0 Karma

lukejadamec
Super Champion

little d means digit, big D means not a digit. Same with w and W for a letter.

grijhwani
Motivator

s is any whitespace character.

Nicksyboy
Explorer

Thanks for the quick response! So - \w is for words, \d is for digits. What is D and S stands for?

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 ...