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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...