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,...)

Labels (1)
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!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...