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!

Continuing Innovation & New Integrations Unlock Full Stack Observability For Your ...

You’ve probably heard the latest about AppDynamics joining the Splunk Observability portfolio, deepening our ...

Monitoring Amazon Elastic Kubernetes Service (EKS)

As we’ve seen, integrating Kubernetes environments with Splunk Observability Cloud is a quick and easy way to ...

Cloud Platform & Enterprise: Classic Dashboard Export Feature Deprecation

As of Splunk Cloud Platform 9.3.2408 and Splunk Enterprise 9.4, classic dashboard export features are now ...