Splunk Search

How do I remove all 1 and 2 character words from a field?

andrewtrobec
Motivator

Hello,
I have a string field containing many words and I would like to remove all 1 and 2 character words from it. How do I do that? If my first sentence was the field value, the resulting output would be:

have string field containing many words and would like remove all and character words from

Best regards,

Andrew

Tags (1)
0 Karma
1 Solution

FrankVl
Ultra Champion

Add the following to your existing search:

| rex field=yourfield mode=sed "s/\b(\w{1,2})\b//g"

https://regex101.com/r/EPipoO/1

View solution in original post

FrankVl
Ultra Champion

Add the following to your existing search:

| rex field=yourfield mode=sed "s/\b(\w{1,2})\b//g"

https://regex101.com/r/EPipoO/1

andrewtrobec
Motivator

That's the one! Thank you!

0 Karma
Get Updates on the Splunk Community!

Accelerating Observability as Code with the Splunk AI Assistant

We’ve seen in previous posts what Observability as Code (OaC) is and how it’s now essential for managing ...

Integrating Splunk Search API and Quarto to Create Reproducible Investigation ...

 Splunk is More Than Just the Web Console For Digital Forensics and Incident Response (DFIR) practitioners, ...

Congratulations to the 2025-2026 SplunkTrust!

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