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!

New This Month in Splunk Observability Cloud - Metrics Usage Analytics, Enhanced K8s ...

The latest enhancements across the Splunk Observability portfolio deliver greater flexibility, better data and ...

Alerting Best Practices: How to Create Good Detectors

At their best, detectors and the alerts they trigger notify teams when applications aren’t performing as ...

Discover Powerful New Features in Splunk Cloud Platform: Enhanced Analytics, ...

Hey Splunky people! We are excited to share the latest updates in Splunk Cloud Platform 9.3.2408. In this ...