Splunk Enterprise

Why is my rex command not working?

rajasplunk89
Engager

Hi all,

I am trying to extract field ABDEF-999 in the name Id. But its not extracting when I use below commands. Could someone guide on what's the mistake in following rex.

|rex field="line" "\"Testcode\":\"(?<id>[^\"]*)\""|table id

 

Extracting from =   \\\"Testcode\\\":\\\"ABDEF-999\\\"

Labels (1)
0 Karma

scelikok
SplunkTrust
SplunkTrust

@rajasplunk89 ,

Sorry, Splunk needs an extra escape for backslash; 

| rex field=line "\"Testcode\S+\":\S+\"(?<id>[^\\\]+)\S+\"" | table id
If this reply helps you an upvote and "Accept as Solution" is appreciated.
0 Karma

rajasplunk89
Engager

Is there anything I can do to resolve the error?

0 Karma

rajasplunk89
Engager

Error in 'rex' command: Encountered the following error while compiling the regex '"Testcode\S+":\S+"(?<id>[^\]+)\S+"': Regex: missing terminating ] for character class

0 Karma

scelikok
SplunkTrust
SplunkTrust

Hi @rajasplunk89,

Below should work;

| rex field=line "\"Testcode\S+\":\S+\"(?<id>[^\\]+)\S+\"" | table id
If this reply helps you an upvote and "Accept as Solution" is appreciated.
0 Karma
Get Updates on the Splunk Community!

Developer Spotlight with Paul Stout

Welcome to our very first developer spotlight release series where we'll feature some awesome Splunk ...

State of Splunk Careers 2024: Maximizing Career Outcomes and the Continued Value of ...

For the past four years, Splunk has partnered with Enterprise Strategy Group to conduct a survey that gauges ...

Data-Driven Success: Splunk & Financial Services

Splunk streamlines the process of extracting insights from large volumes of data. In this fast-paced world, ...