<?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: How do you extract user names from a field that contains an email address? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-extract-user-names-from-a-field-that-contains-an/m-p/449594#M127307</link>
    <description>&lt;P&gt;@PanIrosha, &lt;/P&gt;

&lt;P&gt;Ok, try this and upvote if it worked &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|rex field=userId "(?&amp;lt;user&amp;gt;.+?(?=@))"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 31 Oct 2018 11:25:21 GMT</pubDate>
    <dc:creator>renjith_nair</dc:creator>
    <dc:date>2018-10-31T11:25:21Z</dc:date>
    <item>
      <title>How do you extract user names from a field that contains an email address?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-extract-user-names-from-a-field-that-contains-an/m-p/449589#M127302</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;

&lt;P&gt;I have a data field called "userId" (FirstName.LastName@DomainName)  in one of my data sources. Is there a way to create a new field called "user" just by extracting the "FirstName.LastName" part from the "userId" field ?&lt;/P&gt;

&lt;P&gt;Thank you in advance&lt;/P&gt;</description>
      <pubDate>Tue, 30 Oct 2018 13:22:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-extract-user-names-from-a-field-that-contains-an/m-p/449589#M127302</guid>
      <dc:creator>PanIrosha</dc:creator>
      <dc:date>2018-10-30T13:22:53Z</dc:date>
    </item>
    <item>
      <title>Re: How do you extract user names from a field that contains an email address?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-extract-user-names-from-a-field-that-contains-an/m-p/449590#M127303</link>
      <description>&lt;P&gt;@PanIrosha,&lt;BR /&gt;
Try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your search|rex field=userId "(?&amp;lt;user&amp;gt;\w+\.\w+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In case your names contain digits and - (hyphen) then use,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your search|rex field=userId "(?&amp;lt;user&amp;gt;[\w0-9-]+\.[\w0-9-]+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Oct 2018 13:47:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-extract-user-names-from-a-field-that-contains-an/m-p/449590#M127303</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2018-10-30T13:47:23Z</dc:date>
    </item>
    <item>
      <title>Re: How do you extract user names from a field that contains an email address?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-extract-user-names-from-a-field-that-contains-an/m-p/449591#M127304</link>
      <description>&lt;P&gt;Hi Renjith,&lt;/P&gt;

&lt;P&gt;Thank you very much for the quick response. will you be able to tell me how to create the field adding this this please ? i am quite new to splunk&lt;/P&gt;

&lt;P&gt;Thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt;</description>
      <pubDate>Tue, 30 Oct 2018 15:08:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-extract-user-names-from-a-field-that-contains-an/m-p/449591#M127304</guid>
      <dc:creator>PanIrosha</dc:creator>
      <dc:date>2018-10-30T15:08:44Z</dc:date>
    </item>
    <item>
      <title>Re: How do you extract user names from a field that contains an email address?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-extract-user-names-from-a-field-that-contains-an/m-p/449592#M127305</link>
      <description>&lt;P&gt;@PanIrosha, &lt;BR /&gt;
the user field will be created as its used in the named group. Run the below example to check&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults |eval userId="FirstName.LastName@abc.com" |rex field=userId "(?&amp;lt;user&amp;gt;[\w0-9-]+\.[\w0-9-]+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Oct 2018 16:15:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-extract-user-names-from-a-field-that-contains-an/m-p/449592#M127305</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2018-10-30T16:15:07Z</dc:date>
    </item>
    <item>
      <title>Re: How do you extract user names from a field that contains an email address?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-extract-user-names-from-a-field-that-contains-an/m-p/449593#M127306</link>
      <description>&lt;P&gt;Hi @renjith.nair  &lt;/P&gt;

&lt;P&gt;the regex worked fine in my search. apparently , we have few few naming conventions. some are just &lt;A href="mailto:firstname@domain.com"&gt;firstname@domain.com&lt;/A&gt;. can you help me to create a regex that detect "everything" before @ sign ? &lt;/P&gt;

&lt;P&gt;Thank you very much.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Oct 2018 09:21:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-extract-user-names-from-a-field-that-contains-an/m-p/449593#M127306</guid>
      <dc:creator>PanIrosha</dc:creator>
      <dc:date>2018-10-31T09:21:24Z</dc:date>
    </item>
    <item>
      <title>Re: How do you extract user names from a field that contains an email address?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-extract-user-names-from-a-field-that-contains-an/m-p/449594#M127307</link>
      <description>&lt;P&gt;@PanIrosha, &lt;/P&gt;

&lt;P&gt;Ok, try this and upvote if it worked &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|rex field=userId "(?&amp;lt;user&amp;gt;.+?(?=@))"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 31 Oct 2018 11:25:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-extract-user-names-from-a-field-that-contains-an/m-p/449594#M127307</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2018-10-31T11:25:21Z</dc:date>
    </item>
    <item>
      <title>Re: How do you extract user names from a field that contains an email address?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-extract-user-names-from-a-field-that-contains-an/m-p/449595#M127308</link>
      <description>&lt;P&gt;@renjith.nair &lt;/P&gt;

&lt;P&gt;wow. that work like a charm. thank you very much. this regex work fine when i run in the search bar. i can see the field getting extracted. but how can i save this extraction permanently ? &lt;/P&gt;

&lt;P&gt;i tried to save this as a field extraction in Settings &amp;gt; Fields &amp;gt; Filed Extraction. below are the settings for this extraction&lt;/P&gt;

&lt;P&gt;Destination App: Search&lt;BR /&gt;
Name: User_field_extract&lt;BR /&gt;
Sourcetype: SourceTypeName&lt;BR /&gt;
Type: inline&lt;BR /&gt;
Extraction and Transform:  &lt;CODE&gt;rex field=userId "(?&amp;lt;user&amp;gt;.+?(?=@))"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;App Permission: Global&lt;/P&gt;

&lt;P&gt;in the search bar, i can get the extracted field when i search with index name&lt;/P&gt;

&lt;P&gt;index=asa | &lt;CODE&gt;rex field=userId "(?&amp;lt;user&amp;gt;.+?(?=@))"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;but it doesn't return any results when i search with the sourcetype, source or host.&lt;/P&gt;

&lt;P&gt;any idea wht might be the reason ?&lt;/P&gt;

&lt;P&gt;Thank you very much Renjith.&lt;/P&gt;

&lt;P&gt;NOTE: i am using your exact regex command given in your answers. &lt;/P&gt;

&lt;P&gt;Regards&lt;BR /&gt;
Irosha&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:47:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-extract-user-names-from-a-field-that-contains-an/m-p/449595#M127308</guid>
      <dc:creator>PanIrosha</dc:creator>
      <dc:date>2020-09-29T21:47:08Z</dc:date>
    </item>
    <item>
      <title>Re: How do you extract user names from a field that contains an email address?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-extract-user-names-from-a-field-that-contains-an/m-p/449596#M127309</link>
      <description>&lt;P&gt;@PanIrosha ,&lt;/P&gt;

&lt;P&gt;Hi Irosha,&lt;/P&gt;

&lt;P&gt;Since the search works fine with index=, then the field extraction is working.&lt;/P&gt;

&lt;P&gt;If you haven't given any index name in the search, there is a property in the user role called &lt;CODE&gt;Indexes searched by default&lt;/CODE&gt; which will be looked against to find out the indexes the search should consider by default. Unless you change that property , by default it has only &lt;CODE&gt;main&lt;/CODE&gt; index. You can change that by Settings -&amp;gt; Access controls » Roles » "your role name" and scroll down to find &lt;CODE&gt;Indexes searched by default&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Oct 2018 11:53:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-extract-user-names-from-a-field-that-contains-an/m-p/449596#M127309</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2018-10-31T11:53:59Z</dc:date>
    </item>
    <item>
      <title>Re: How do you extract user names from a field that contains an email address?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-extract-user-names-from-a-field-that-contains-an/m-p/449597#M127310</link>
      <description>&lt;P&gt;@renjith.nair &lt;/P&gt;

&lt;P&gt;thank you for the prompt response. did i use the correct way to create the field extraction ? is there anything need to be added ?&lt;/P&gt;

&lt;P&gt;i tried to save this as a field extraction in Settings &amp;gt; Fields &amp;gt; Filed Extraction. below are the settings for this extraction&lt;/P&gt;

&lt;P&gt;Destination App: Search&lt;BR /&gt;
Name: User_field_extract&lt;BR /&gt;
Sourcetype: SourceTypeName&lt;BR /&gt;
Type: inline&lt;BR /&gt;
Extraction and Transform: rex field=userId "(?.+?(?=@))"&lt;/P&gt;

&lt;P&gt;App Permission: Global&lt;/P&gt;

&lt;P&gt;Thank you very much.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:47:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-extract-user-names-from-a-field-that-contains-an/m-p/449597#M127310</guid>
      <dc:creator>PanIrosha</dc:creator>
      <dc:date>2020-09-29T21:47:11Z</dc:date>
    </item>
  </channel>
</rss>

