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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...