Splunk Search

Extracting a field from delimeter value

zacksoft_wf
Contributor

My fields have values like,

UTR998760071.unot.utrl.accorda.net
RANWA80A8881.cnet.utrl.matrixia.net
ANNA00A0071.tron.utrl.zimbaw.net
BP87DF087071.cnet.trzn.netisha.net

I want the fist part of the string to be extracted. The part before the first .(dot)

output be like 
UTR998760071
RANWA80A8881
ANNA00A0071
BP87DF087071

Not with substr but with a regex preferably.
Thank you



Labels (2)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

There are a couple of ways to do that.

The first uses rex:

... | rex field=foo "(?<newField>[^\.]+)"

The other uses the split function.

... | eval newField=mvindex(split(field, "."), 0)
---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

There are a couple of ways to do that.

The first uses rex:

... | rex field=foo "(?<newField>[^\.]+)"

The other uses the split function.

... | eval newField=mvindex(split(field, "."), 0)
---
If this reply helps you, Karma would be appreciated.

zacksoft_wf
Contributor

Some of my fields demand extraction of other fields  between the delimeter.
Any rex that could help me to get all the values between the delimeters  please ?

UTR998760071.unot.utrl@accorda.net
(some delimeters are .(dot) and some are (@)

Output should be 
UTR998760071
unot
utrl

accorda
net




Tags (1)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

That's a big change from the original question.  Are the fields always in the same format (5 parts) or does it vary?  Please provide all requirements so we can answer the question correctly.

---
If this reply helps you, Karma would be appreciated.
0 Karma

zacksoft_wf
Contributor

Yes, they are all same format. (5 parts)
And I have to extract all 5 parts delimeted by .(dot) and @

Example : UTR998760071.unot.utrl@accorda.net

0 Karma

richgalloway
SplunkTrust
SplunkTrust

This regex should get all 5 fields.

(?<field1>[^\.]+)\.(?<field2>[^\.]+)\.(?<field3>[^@]+)@(?<field4>[^\.]+)\.(?<field5>.*)
---
If this reply helps you, Karma would be appreciated.
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...