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
Ultra Champion

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!

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