All Apps and Add-ons

How to use the extracted field expressions using rex command ?

Real_captain
Path Finder

HI 

Can someone please let me know how I can use the below expression (generated via Field Extraction) directly via Rex command: 

Regular expression generated via Field extraction:

 

^(?:[^,\n]*,){7}\s+"\w+_\w+_\w+_\w+_\w+":\s+"(?P<POH>[^"]+)

 

Real_captain_1-1728224376355.png

Real_captain_0-1728224337078.png

I am using the rex command as below but i am getting an error : 

 

| rex field=Message mode=sed "(?:[^,\n]*,){7}\s+"\w+_\w+_\w+_\w+_\w+":\s+"(?P<POH1>[^"]+)"

 

Labels (1)
0 Karma

inventsekar
SplunkTrust
SplunkTrust

Hi @Real_captain , the mode=sed was not from the field extraction wizard. may i know why you thought to use the mode=sed, pls suggest. 


As you can see, 

Syntax: mode=sed Description: Specify to indicate that you are using a sed (UNIX stream editor) expression. sed-expression Syntax: "<string>" Description: When mode=sed, specify whether to replace strings (s) or substitute characters (y) in the matching regular expression. 

https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Rex#Syntax


not sure, but lets try:

 

| rex field=Message "(?:[^,\n]*,){7}\s+"\w+_\w+_\w+_\w+_\w+":\s+"(?P<POH1>[^"]+)"

 

 

Sample log lines will be helpful to troubleshoot this, thanks.  

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Index This | What travels the world but is also stuck in place?

April 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...