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!

Join Us at the Builder Bar at .conf24 – Empowering Innovation and Collaboration

What is the Builder Bar? The Builder Bar is more than just a place; it's a hub of creativity, collaboration, ...

Combine Multiline Logs into a Single Event with SOCK - a Guide for Advanced Users

This article is the continuation of the “Combine multiline logs into a single event with SOCK - a step-by-step ...

Everything Community at .conf24!

You may have seen mention of the .conf Community Zone 'round these parts and found yourself wondering what ...