Splunk Search

What regex command to use to to remove the special character after a number?

DataOrg
Builder

I want to remove the special character after a number, please help.

data:

7.62\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00

I want:

7.62. the number is not constant it will keep changing so I need to remove only the special character.
0 Karma

richgalloway
SplunkTrust
SplunkTrust

@493669 has a good answer, but types faster than me. It will extract the number into a new field.

Here's another option that modifies the original field (not on disk, of course).

... | rex mode=sed field=data "s/\\\x00//g" | ...
---
If this reply helps you, Karma would be appreciated.
0 Karma

493669
Super Champion

try this:

   ... |rex field=data "^(?<data>\d+\.?\d+)"

or

   ... |rex field=data "^(?<a>[^\\]+)"
0 Karma

sudosplunk
Motivator

Hi there,

Is this how the full event looks like? Can you please provide some sample events to give you the regex as accurate as possible.
Also, do you want to remove special characters before indexing or after (search-time)?

0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...