Splunk Search

What is the best way to get regex sed to remove any words with numbers?

subtrakt
Contributor

Trying to get ideas on the best efficient/simple rex mode=sed to replace any words with a number(s).

Examples of what should be replaced:

0909asdf009
asdf9090-333234aaf
asdf009sdd
3039aaa:
aa33--33aa-3039:

This is nice and compact but doesn't seem to work the way I thought it would as i'm still getting fragments of the word in my results.

s/[\w\W?]+[0-9]/ /g

UPDATE:
Think this is closer but curious to see what others say:
([A-Za-z0-9-.,:_]+)[0-9]+

Tags (2)
0 Karma
1 Solution

elliotproebstel
Champion

How about this regex: (\S*[0-9]+)+\S* ? If it doesn't work, you can post some counterexamples, and I'll refine. It works with all examples above.

View solution in original post

elliotproebstel
Champion

How about this regex: (\S*[0-9]+)+\S* ? If it doesn't work, you can post some counterexamples, and I'll refine. It works with all examples above.

subtrakt
Contributor

Thanks Elliot. That works. Looks like this also works \S*\d+\S*.

0 Karma

elliotproebstel
Champion

Ah, true! Good simplification 🙂

Get Updates on the Splunk Community!

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...