Splunk Search

How to remove or replace "-" from a field)?

hellothere
Engager

Hello all, 

I have a field that contains hypens in the value.  For example, 20.0--(1259). 

I am simply trying to replace it with space, but it does not work.  could you tell me what am I doing wrong? 

 

index=main
| eval version_name = replace(version, "-", "  ")

Labels (4)
Tags (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Your code looks OK - unless your real field name has special characters in - in which case, put it in single quotes.

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Your code looks OK - unless your real field name has special characters in - in which case, put it in single quotes.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Please explain what you mean by "it does not work".  Your code works fine in my Splunk sandbox.  "20.0--(1259)" becomes "20.0 (1259)".

---
If this reply helps you, Karma would be appreciated.
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 ...