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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...