Splunk Search

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

rohanmiskin
Explorer

I have logs having string like:

127.0.0.1|> GET /alldata
127.0.0.1|> GET /somedata
127.0.0.1|> GET /nodata
127.0.0.1|> POST /nodata
127.0.0.1|> PUT /nodata
127.0.0.1|> DELETE /nodata

I want to extract the field between 127.0.0.1|> 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

vnravikumar
Champion

Hi @rohanmiskin

Try this and let me know

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

renjith_nair
Legend

@rohanmiskin ,

Try

"\>\s(?<ACTION>\w+)"
---
What goes around comes around. If it helps, hit it with Karma 🙂
Get Updates on the Splunk Community!

Splunk Observability Cloud’s AI Assistant in Action Series: Analyzing and ...

This is the second post in our Splunk Observability Cloud’s AI Assistant in Action series, in which we look at ...

Elevate Your Organization with Splunk’s Next Platform Evolution

 Thursday, July 10, 2025  |  11AM PDT / 2PM EDT Whether you're managing complex deployments or looking to ...

Splunk Answers Content Calendar, June Edition

Get ready for this week’s post dedicated to Splunk Dashboards! We're celebrating the power of community by ...