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!

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!

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

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...