Hi,
I have been tinkering with regex101 for some time now and no luck.
I have a field called sender
Return-Path:<someName@someDomain.com>
Return-Path:<someName@someDomain.com.blah>
I want to regex the sender so that I get
someDomain.com
someDomain.com.blah
So I want the string to start after @ and end before >
here is what I started with
... | rex field=sender "@(?<domain>.*)"
Thank you
Close, try this:
| rex field=sender "@(?<domain>[^\>]+)"
You want to read only characters not equal to >
. https://regex101.com/r/WbsXgT/1
I like this approach myself
(?<=@)(?<domainName>.*)(?=>)
Any reason for why you like that approach? It is harder to read and if I interpret the regex101 execution info correctly a lot less efficient than a straightforward "@(?<domain>.[^\>]+)"
.
Given the 2 line sample from the question, regex101 reports 13 steps for my solution and 125 steps for yours.
Oh it’s less efficient for sure. I like it because it opens the user’s eyes to reverse and forward lookups etc.
thanks, I will check it out
Just add the >
, such as - ... | rex field=sender "@(?<domain>.*)>"
Try this:
| rex field=sender "@(?<domain>.[^\>]+)"
"@(?<domain>.*)>"
Close, try this:
| rex field=sender "@(?<domain>[^\>]+)"
You want to read only characters not equal to >
. https://regex101.com/r/WbsXgT/1