Splunk Dev

Regex to remove all the special charater from date and convert it as a string

JyotiP
Path Finder

I have a variable temp = 2019/19/09_04:02:49:344 and I want to remove all the special character from it like 20191909040249344.

Tags (1)
0 Karma
1 Solution

jpolvino
Builder

Rather than list every possible special character, another way is to exclude characters that are non-digits:

| makeresults 
| eval temp="2019/19/09_04:02:49:344"
| rex mode=sed field=temp "s/[\D]+//g"

View solution in original post

0 Karma

jpolvino
Builder

Rather than list every possible special character, another way is to exclude characters that are non-digits:

| makeresults 
| eval temp="2019/19/09_04:02:49:344"
| rex mode=sed field=temp "s/[\D]+//g"
0 Karma

harsmarvania57
SplunkTrust
SplunkTrust

Hi,

If you want to remove special character during search time, you can try below search. In below example I am assuming that you have time in temp field

<yourBaseSearch>
| rex mode=sed field=temp "s/[_!@#$%^&*(),.?\":{}|<>\/\\\\]//g"

xaratos
Explorer

Like every special character? So that you have 20191909040249344?

0 Karma

JyotiP
Path Finder

@xaratos yeah, every special character

0 Karma

xaratos
Explorer
0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...