Splunk Search

What is the best way to compare emails in two different formats

mlevsh
Builder

I have two fields, I need to compare, that contain an email address, but in different format:
Format 1) firstname.lastname@domain.com
Format 2) firstname_lastname_domain_com

What's the best way to compare those fields?

Thank you in advance

0 Karma
1 Solution

elliotproebstel
Champion

Personally, I'd convert the events with the first format to match the second format and then compare them. It would be something like this run anywhere command:
| makeresults| eval first="first.last@test.com", second="first_last_test_com" | eval compare_first=first | rex mode=sed field=compare_first "s/[\.@]/_/g" | where compare_first=second

And if you didn't need to preserve the first one, you could make it even easier:
| makeresults| eval first="first.last@test.com", second="first_last_test_com" | rex mode=sed field=first "s/[\.@]/_/g" | where first=second

View solution in original post

elliotproebstel
Champion

Personally, I'd convert the events with the first format to match the second format and then compare them. It would be something like this run anywhere command:
| makeresults| eval first="first.last@test.com", second="first_last_test_com" | eval compare_first=first | rex mode=sed field=compare_first "s/[\.@]/_/g" | where compare_first=second

And if you didn't need to preserve the first one, you could make it even easier:
| makeresults| eval first="first.last@test.com", second="first_last_test_com" | rex mode=sed field=first "s/[\.@]/_/g" | where first=second

mlevsh
Builder

Thank you @elliotproebstel for your suggestions. Will try to use that!
I've converted the regular formatted email "firstname.lastname@domain.com" to the second format by
replacing "." and "@" with "_":

Field "userid" had value firstname.lastname@domain.com.

...|eval useridformated = replace(userid,"\.","_") | eval useridformated = replace(useridformated,"@","_") ...
0 Karma

kmaron
Motivator

you could always convert one to the other format then directly compare them using regular expressions
or break up the address into fields (firstname, lastname, domain, etc) and compare each piece directly.

0 Karma
Get Updates on the Splunk Community!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...