Splunk Search

Case statement with a regex?

klim
Path Finder

I'm trying to use a case statement and assign part of a field for each case statement. For example case(len(field)=5, regex that takes the first 3 characters of field, len(field=7), regex takes the first 5 characters,...)

0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Are you always trying to get everything apart from the last two characters?

| eval part=substr(field,1,len(field)-2)

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Are you always trying to get everything apart from the last two characters?

| eval part=substr(field,1,len(field)-2)
0 Karma

klim
Path Finder

no that was just a coincidence but i think you provided the answer. Substr will do since each different length I want a substring of the field and it can be used in the case statement. Thanks

0 Karma
Get Updates on the Splunk Community!

AppDynamics Summer Webinars

This summer, our mighty AppDynamics team is cooking up some delicious content on YouTube Live to satiate your ...

SOCin’ it to you at Splunk University

Splunk University is expanding its instructor-led learning portfolio with dedicated Security tracks at .conf25 ...

Credit Card Data Protection & PCI Compliance with Splunk Edge Processor

Organizations handling credit card transactions know that PCI DSS compliance is both critical and complex. The ...