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!

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...