Splunk Search

Check if field match the regex?

boxmetal
Path Finder

Hi Splunk Community,

I need help to check whether my directory field match the regex

The regex I used is ^\w+:\\root_folder\\((?:(?!excluded_folder).)*?)\\    to check the file path does not belong to the excluded_folder

Example: c:\root_folder\excluded_folder\...\...\...\file  is False

d:\root_folder\subfolder\...\...\...\file is True

Could anyone please help? Much appreciated!

Labels (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| eval excluded=if(match(directory,"^\w+:\\\\root_folder\\\\((?:(?!excluded_folder).)*?)\\\\"), "true", "false")

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust
| eval excluded=if(match(directory,"^\w+:\\\\root_folder\\\\((?:(?!excluded_folder).)*?)\\\\"), "true", "false")

boxmetal
Path Finder

Thanks @ITWhisperer 

This solved my issue

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @boxmetal,

you couldextract the folder_to_chek field and make the check on this field. something like this:

<yur_search>
| rex field=source "^\w:\\\w+\\(?<folder_to_check>\w+)"
| search folder_to_check="subfolder"

Ciao.

Giuseppe

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