Splunk Search

How to combine Fw: and Fwd in email Subjects

smurfy_91
New Member

Let's say I had used a search like:

index=mail RecipientUserDomain=user@domain.com | stats count by Subject | sort-count |

and returned results such as:

Subject

Fwd: This is a subject
Fw: This is a subject
Random Subject
Fwd: Another subject
Different Subject
Fw: Another Subject

What can I use to remove the "Fwd:" & "Fw:" from the Subject to combine the counts?

0 Karma

richgalloway
SplunkTrust
SplunkTrust

There are a few ways to do that.

... | replace "Fw*: " with "" in Subject | stats ...

... | rex field=Subject mode=sed "s/Fwd?:\s(.*)/\1/" | stats ...

... | rex field=Subject "Fwd?: (?<Subject>.*)" | stats ...
---
If this reply helps you, Karma would be appreciated.
0 Karma

koshyk
Super Champion

Please have a try

index=mail RecipientUserDomain=user@domain.com | rex field=Subject "(Fw(.?)\:(\s+))?(?<mysubject>.+)" | stats count by mysubject | sort -count 

Example

|makeresults| eval Subject="Fwd: This is a subject||Fw: This is a subject||Random Subject||Fwd: Another Subject||Different Subject||Fw: Another Subject"| makemv delim="||" Subject | mvexpand Subject | rex field=Subject "(Fw(.?)\:(\s+))?(?<mysubject>.+)" | stats count by mysubject | sort -count

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

0 Karma
Get Updates on the Splunk Community!

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 ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...