Splunk Search

I have field DivionsID with data of Exe.123, how to trim this to just 123 ?

sumandevops
Engager

I have field DivionsID with data of Exe.123, how to trim this to just 123 ?

Labels (1)
0 Karma

scelikok
SplunkTrust
SplunkTrust

If you want to overwrite the field it should work;

| rex field = DivisionId "(?<DivisionId>\d+)"
If this reply helps you an upvote and "Accept as Solution" is appreciated.
0 Karma

venky1544
Builder

ideally regex should work if not you could try the replace command something like below

|makeresults |eval data="Exe.123" |replace "Exe.123" with "123" |table data

0 Karma

sumandevops
Engager

I didn't get you, please elaborate 

0 Karma

venky1544
Builder

HI Suman 

you wanted to trim the data Exe.123 to 123 right so you can either use regex like others or specifying or use the replace command 

it would be great if could share the more about the data and what command are you executing with regex 

its not helping when you say its not working or please elaborate 

 

0 Karma

sumandevops
Engager

why create a new field div_no? 

| rex filed = DivisionId " (?<DivisionId>\d+)" wouldn’t work?

 

 

0 Karma

scelikok
SplunkTrust
SplunkTrust

Hi @sumandevops,

You can use rex command, below will output a new field div_no.

| rex field=DivionsID "(?<div_no>\d+)"

 

If this reply helps you an upvote and "Accept as Solution" is appreciated.
0 Karma

sumandevops
Engager

this is not working mate

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...