Splunk Search

strip portion of an email

brownt61
Explorer

I am needing to strip a portion out of email's. I have a list of email addresses where some of them contain -priv before the @ that I need stripped out leaving what would be the "normal" email address.

example address
example-priv@email.com

I want to be left with example@email.com

can someone help me with the rex for this?

thank you

0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Try | rex field=email mode=sed "s/-priv//"

---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

Try | rex field=email mode=sed "s/-priv//"

---
If this reply helps you, Karma would be appreciated.

brownt61
Explorer

Thank you, this worked

0 Karma

woodcock
Esteemed Legend

Like this:

| makeresults 
| eval email="example-priv@email.com" 
| rex field=email mode=sed "s/-[^@]+@/@/g"
0 Karma

brownt61
Explorer

Thank you, I should add that I have since noticed that there are email addresses that have an appropriate need to have - in them.

example
surname.givenname-middlename-priv@email.com

so I really need to only strip emails that have -priv in them, not any email that contains a - from the - to @

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!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

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