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!

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...