Splunk Search

Another rex field with backslashes question.

rfiscus
Path Finder

I can test

\\[\w]+\\[\w]+\\(?<File_Path>.+) or simply \\\w+\\\w+\\(?<File_Path>.+)

in Rex101 and it works fine

In Splunk, | rex field=_raw "\[\w]+\[\w]+\(?<File_Path>.+)"

I get Regex: unmatched closing parenthesis.

What would be the proper way to escape the backslashes in Splunk, I have search for examples but with no definitive answers?

Raw data:

Application Information:
Process ID: 3160
Application Name: \device\harddiskvolume4\program files\common files\microsoft shared\clicktorun\officeclicktorun.exe

Network Information:
Direction: Outbound

I just want the output to be:

program files\common files\microsoft shared\clicktorun\officeclicktorun.exe

in this example.

 

Labels (2)
0 Karma
1 Solution

rfiscus
Path Finder

Haha, I tried two and four, apparently didn't try three.  Thanks!

View solution in original post

0 Karma

scelikok
SplunkTrust
SplunkTrust

Hi @rfiscus,

You should add one more backslash for escape backslash like below;

| rex field=_raw "\\\[\w]+\\\[\w]+\\\(?<File_Path>.+)"

 

If this reply helps you an upvote and "Accept as Solution" is appreciated.
0 Karma

rfiscus
Path Finder

Haha, I tried two and four, apparently didn't try three.  Thanks!

0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...