Splunk Search

How do I extract a field between two strings using a regular expression?


I have logs having string like:|> GET /alldata|> GET /somedata|> GET /nodata|> POST /nodata|> PUT /nodata|> DELETE /nodata

I want to extract the field between|> and /
i.e i need GET,POST,PUT,DELETE to be in an extracted field.

NOTE: There's a space after > and before /

0 Karma


Hi @rohanmiskin

Try this and let me know

| makeresults 
| eval sampledata ="|> GET /somedata" 
| rex field="sampledata" ">\s(?P<method>.*)\s\/"
0 Karma


@rohanmiskin ,


What goes around comes around. If it helps, hit it with Karma 🙂
Get Updates on the Splunk Community!

Detecting Remote Code Executions With the Splunk Threat Research Team

WATCH NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If exploited, ...

Enter the Splunk Community Dashboard Challenge for Your Chance to Win!

The Splunk Community Dashboard Challenge is underway! This is your chance to showcase your skills in creating ...

.conf24 | Session Scheduler is Live!!

.conf24 is happening June 11 - 14 in Las Vegas, and we are thrilled to announce that the conference catalog ...