<?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 for extracting email with a trailing whitespace in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-email-with-a-trailing-whitespace/m-p/368187#M108532</link>
    <description>&lt;P&gt;This line, in a search, will alter field EMAIL so that all spaces are deleted.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=EMAIL mode=sed "s/ //g"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can also sedmode the events at the indexer while you are ingesting them, which alters the underlying &lt;CODE&gt;_raw&lt;/CODE&gt; data.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;SEDCMD-foo s/(\[EMAIL=)(\s*)(\S*)(\s*)(\S*)(\s*)(\])/\1\3\5\7/g
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 13 Nov 2017 18:58:51 GMT</pubDate>
    <dc:creator>DalJeanis</dc:creator>
    <dc:date>2017-11-13T18:58:51Z</dc:date>
    <item>
      <title>Regex for extracting email with a trailing whitespace</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-email-with-a-trailing-whitespace/m-p/368183#M108528</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have log line according to the next template: [2017-11-03 13:55:52,945] [MYPROJ] &lt;STRONG&gt;[EMAIL=&lt;A href="mailto:xxx@yyy.com"&gt;xxx@yyy.com&lt;/A&gt;]&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;But I want to find users (EMAIL) where the user inserted a whitespace at the start/end of the email:  [2017-11-03 13:55:52,945] [MYPROJ] &lt;STRONG&gt;[EMAIL=&lt;A href="mailto:xxx@yyy.com"&gt;xxx@yyy.com&lt;/A&gt; ]&lt;/STRONG&gt; &amp;lt;- notice the end of the email&lt;/P&gt;

&lt;P&gt;Somehow no regex will find it.&lt;/P&gt;

&lt;P&gt;Is there something in the splunk admin conf that will trim the whitespace automatically?&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 13:43:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-email-with-a-trailing-whitespace/m-p/368183#M108528</guid>
      <dc:creator>nmayafit</dc:creator>
      <dc:date>2017-11-13T13:43:17Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for extracting email with a trailing whitespace</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-email-with-a-trailing-whitespace/m-p/368184#M108529</link>
      <description>&lt;P&gt;&lt;CODE&gt;| rex "(?&amp;lt;email_with_trailing_space&amp;gt;\[EMAIL=[^]]+ \])" | search email_with_trailing_space=*&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;That will extract the full [EMAIL=...] portion of the log and allow you to search for a space before the closing ].&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 15:55:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-email-with-a-trailing-whitespace/m-p/368184#M108529</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2017-11-13T15:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for extracting email with a trailing whitespace</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-email-with-a-trailing-whitespace/m-p/368185#M108530</link>
      <description>&lt;P&gt;HI,&lt;/P&gt;

&lt;P&gt;Can you please try rex? This rex will extract EMAIL ID and blank space (if any)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;.*EMAIL=(?&amp;lt;EMAIL_ID&amp;gt;.*)(?&amp;lt;BLANK_SPACE&amp;gt;[|.\s])
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can try below search also.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;YOUR_SEARCH
| rex field=_raw.*EMAIL=(?&amp;lt;EMAIL_ID&amp;gt;.*)(?&amp;lt;BLANK_SPACE&amp;gt;[|.\s])
| table _time EMAIL_ID BLANK_SPACE
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This search will list you eail_is as well as BLANK  Space at ed of email id(if any).&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 15:57:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-email-with-a-trailing-whitespace/m-p/368185#M108530</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2017-11-13T15:57:59Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for extracting email with a trailing whitespace</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-email-with-a-trailing-whitespace/m-p/368186#M108531</link>
      <description>&lt;P&gt;Great catch. REALLY not according to splunk's docs ([\s] etc.)&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 16:44:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-email-with-a-trailing-whitespace/m-p/368186#M108531</guid>
      <dc:creator>nmayafit</dc:creator>
      <dc:date>2017-11-13T16:44:30Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for extracting email with a trailing whitespace</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-email-with-a-trailing-whitespace/m-p/368187#M108532</link>
      <description>&lt;P&gt;This line, in a search, will alter field EMAIL so that all spaces are deleted.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=EMAIL mode=sed "s/ //g"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can also sedmode the events at the indexer while you are ingesting them, which alters the underlying &lt;CODE&gt;_raw&lt;/CODE&gt; data.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;SEDCMD-foo s/(\[EMAIL=)(\s*)(\S*)(\s*)(\S*)(\s*)(\])/\1\3\5\7/g
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Nov 2017 18:58:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-extracting-email-with-a-trailing-whitespace/m-p/368187#M108532</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-11-13T18:58:51Z</dc:date>
    </item>
  </channel>
</rss>

