Splunk Search

Trim string after second exclamation mark

mandlikarbaaz
Loves-to-Learn Everything

Hi,
I have a field called SESSION_ID which has a value "0cdWYCu982HhTjoSYMUgnrCIW8c1apbU!1706637738!1581997108157"
I want to trim or modify the string from the second exclamation to the last to make it look like this "0cdWYCu982HhTjoSYMUgnrCIW8c1apbU!1706637738"
Can someone please help me out!

Tags (1)
0 Karma

vnravikumar
Champion

Hi

Try this

| makeresults 
| eval SESSION_ID ="0cdWYCu982HhTjoSYMUgnrCIW8c1apbU!1706637738!1581997108157" 
| eval SESSION_ID=replace(SESSION_ID,"(![^!]+)$","")
0 Karma

nickhills
Ultra Champion

Try:

|rex field=SESSION_ID "(?P<NEW_SESSION_ID>[^!]+![^!]+)"

If my comment helps, please give it a thumbs up!

nickhills
Ultra Champion

If my answer helped, please consider accepting and/or upvoting so that other memebers of the community can see it was useful.

If my comment helps, please give it a thumbs up!
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 ...