<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Regex to extract email domain name in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-email-domain-name/m-p/370674#M109084</link>
    <description>&lt;P&gt;It doesn't work with this example: &lt;A href="mailto:firstname.surname@test.co.uk"&gt;firstname.surname@test.co.uk&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Any thoughts?&lt;/P&gt;</description>
    <pubDate>Wed, 21 Mar 2018 16:22:26 GMT</pubDate>
    <dc:creator>davidcraven02</dc:creator>
    <dc:date>2018-03-21T16:22:26Z</dc:date>
    <item>
      <title>Regex to extract email domain name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-email-domain-name/m-p/370672#M109082</link>
      <description>&lt;P&gt;I have two regexes below which are pulling the domain name of the email sender (from). i.e linkedin.com, amazones.com. &lt;/P&gt;

&lt;P&gt;However I cant create one regex to pull them both in one as they aren't always in the same format.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=fortimail source=/var/log/messages/splunk/fortimail/*-fortimail.log 
| dedup   date, time, to, from, domain, subject
| rex field=from "(.*@.*\.(?&amp;lt;domainname&amp;gt;.*\..*)$)"
| rex field=from ".*@(?&amp;lt;domainname2&amp;gt;.*\..*)$" 
| table date, time, to, from, domainname, domainname2, subject, message_length
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/4590iFA4B09877A390D0C/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2018 15:24:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-email-domain-name/m-p/370672#M109082</guid>
      <dc:creator>davidcraven02</dc:creator>
      <dc:date>2018-03-21T15:24:02Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to extract email domain name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-email-domain-name/m-p/370673#M109083</link>
      <description>&lt;P&gt;This should work with any domain (not just .com):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex field=from ".*?(?&amp;lt;domainname&amp;gt;[\w]+\.[\w]+)$"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Edit:&lt;BR /&gt;
Example - &lt;A href="https://regex101.com/r/1uTWmD/1/"&gt;https://regex101.com/r/1uTWmD/1/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2018 15:43:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-email-domain-name/m-p/370673#M109083</guid>
      <dc:creator>BearMormont</dc:creator>
      <dc:date>2018-03-21T15:43:20Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to extract email domain name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-email-domain-name/m-p/370674#M109084</link>
      <description>&lt;P&gt;It doesn't work with this example: &lt;A href="mailto:firstname.surname@test.co.uk"&gt;firstname.surname@test.co.uk&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Any thoughts?&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2018 16:22:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-email-domain-name/m-p/370674#M109084</guid>
      <dc:creator>davidcraven02</dc:creator>
      <dc:date>2018-03-21T16:22:26Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to extract email domain name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-email-domain-name/m-p/370675#M109085</link>
      <description>&lt;P&gt;Try this generic example&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval to="tiago@lalala.domain1.com" 
| append [ | makeresults 
| eval to="tiago@domain2.com" ]
| append [ | makeresults | eval to="firstname.surname@test.co.uk" ]
| rex field=to "@(.*\.)*(?&amp;lt;Domain&amp;gt;.*\..*)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The test.co.uk is an outlier to this rule? Did you want domain to be test.co.uk? Then you have the same exact format but you want two different behaviours?&lt;/P&gt;

&lt;P&gt;Regex doesn't work like that&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2018 16:40:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-email-domain-name/m-p/370675#M109085</guid>
      <dc:creator>tiagofbmm</dc:creator>
      <dc:date>2018-03-21T16:40:15Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to extract email domain name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-email-domain-name/m-p/370676#M109086</link>
      <description>&lt;P&gt;This is a generically difficult problem. Differentiating domains from subdomains requires a priori knowledge of all top level domains (TLDs), because a domain is really just &lt;CODE&gt;something.valid-tld&lt;/CODE&gt;, where &lt;CODE&gt;something&lt;/CODE&gt; is composed of letters, numbers, and hyphens (if the hyphens are surrounded on both sides by letters, numbers, or other hypens; &lt;A href="https://en.wikipedia.org/wiki/Domain_name"&gt;hyphens may not be the first or last character in a domain name&lt;/A&gt;). &lt;/P&gt;

&lt;P&gt;To that end, you could build something yourself that does this, but you'd be reinventing the wheel. You might want to check out &lt;A href="https://www.splunk.com/blog/2017/09/21/ut-parsing-domains-like-house-slytherin.html"&gt;this blog post on UT_parsing&lt;/A&gt;, which describes a few Splunk add-ons/apps that you could leverage in your work.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2018 17:13:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-email-domain-name/m-p/370676#M109086</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2018-03-21T17:13:48Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to extract email domain name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-email-domain-name/m-p/370677#M109087</link>
      <description>&lt;P&gt;Thank you! Yes i thought I was maybe over complicating it. &lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2018 17:16:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-email-domain-name/m-p/370677#M109087</guid>
      <dc:creator>davidcraven02</dc:creator>
      <dc:date>2018-03-21T17:16:12Z</dc:date>
    </item>
  </channel>
</rss>

