Splunk Search

How to use windcard with spcial charaters to trim a field

nirmalya2006
Path Finder

Hi All

I have a field which has urls in this pattern

GET /echo/index?page=content&id=PRO19579&viewlocale=es_ES HTTP/1.1  

I have to extract only the part "page=content" from it.
I tried to extract it using substr and rtrim but I am unable to trim contents after &.
My search string is

| eval URL = substr(field7,17) | eval URL = rtrim(URL,"^\\&*") 

Please help.

Tags (1)
0 Karma

davebrooking
Contributor

Given your example above, what should the field URL contain?

Dave

0 Karma

nirmalya2006
Path Finder

The field URL should contain "content".

0 Karma

sundareshr
Legend

Try regex (updated to include in code block the <url> shows correctly

  ..| rex " \?page=(?<url>[^&]+)" | ...
0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...