<?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 help - disregard everything after a match in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regex-help-disregard-everything-after-a-match/m-p/449843#M127375</link>
    <description>&lt;P&gt;Thx &lt;/P&gt;

&lt;P&gt;I tried \w+ (&lt;A href="https://regex101.com/r/nInHIF/1"&gt;https://regex101.com/r/nInHIF/1&lt;/A&gt;) but still matches everything after blah.edu:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;blah.edu","Status":"Delivered","Size":"0"}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 26 Jun 2019 14:49:22 GMT</pubDate>
    <dc:creator>jwalzerpitt</dc:creator>
    <dc:date>2019-06-26T14:49:22Z</dc:date>
    <item>
      <title>Regex help - disregard everything after a match</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-help-disregard-everything-after-a-match/m-p/449839#M127371</link>
      <description>&lt;P&gt;I have the following regex that is pulling the sender and receiver domains:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"SenderAddress":"\w+.*@(?&amp;lt;s_domain&amp;gt;.*)","RecipientAddress":"\w+.*@(?&amp;lt;r_domain&amp;gt;.*)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The issue I have is that there are some emails that don't have the 'Subject' field right after the receiver domain.&lt;/P&gt;

&lt;P&gt;How can I write my regex that once it's done matching the receiver domain, it ignores everything after which will address when fields are missing?&lt;/P&gt;

&lt;P&gt;Thx&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2019 14:24:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-help-disregard-everything-after-a-match/m-p/449839#M127371</guid>
      <dc:creator>jwalzerpitt</dc:creator>
      <dc:date>2019-06-26T14:24:01Z</dc:date>
    </item>
    <item>
      <title>Re: Regex help - disregard everything after a match</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-help-disregard-everything-after-a-match/m-p/449840#M127372</link>
      <description>&lt;P&gt;@jwalzerpitt instead of .* use \w+&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2019 14:32:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-help-disregard-everything-after-a-match/m-p/449840#M127372</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2019-06-26T14:32:56Z</dc:date>
    </item>
    <item>
      <title>Re: Regex help - disregard everything after a match</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-help-disregard-everything-after-a-match/m-p/449841#M127373</link>
      <description>&lt;P&gt;Hi jwalzerpitt,&lt;BR /&gt;
could you share two examples of your logs, one for each kind of log?&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2019 14:34:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-help-disregard-everything-after-a-match/m-p/449841#M127373</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-06-26T14:34:46Z</dc:date>
    </item>
    <item>
      <title>Re: Regex help - disregard everything after a match</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-help-disregard-everything-after-a-match/m-p/449842#M127374</link>
      <description>&lt;P&gt;Thx for the reply.&lt;/P&gt;

&lt;P&gt;Here is an email in its raw format with the Subject field present:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{"EventReceivedTime":"2019-06-26 09:52:21","SourceModuleName":"EXCHGETMESGTRACEPRD","SourceModuleType":"im_file","MessageId":"&amp;lt;eb63e665210e9449d5b386d1ae679faa@3e723b591bdb95ce8f5c9b7032dc572ca97351d0da5efc73459c1fbaf438e43b&amp;gt;","Received":"6/26/2019 9:39:47 AM","SenderAddress":"notification@facebookmail.com","RecipientAddress":"user@blah.edu","Subject":"See Who Liked Your Page","Status":"Delivered","FromIP":"69.171.232.138","Size":"56928"}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here is an email in its raw format with the Subject field missing:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{"EventReceivedTime":"2019-06-26 09:47:53","SourceModuleName":"EXCHGETMESGTRACEPRD","SourceModuleType":"im_file","MessageId":"&amp;lt;0100016b93ffa54d-a8a96a78-94b0-46e6-aed6-c0e82ef6d228-000000@email.amazonses.com&amp;gt;","Received":"6/26/2019 9:35:33 AM","SenderAddress":"DoNotReply@ConnectedCommunity.org","RecipientAddress":"jfz5@blah.edu","Status":"Delivered","Size":"0"}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thx&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2019 14:46:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-help-disregard-everything-after-a-match/m-p/449842#M127374</guid>
      <dc:creator>jwalzerpitt</dc:creator>
      <dc:date>2019-06-26T14:46:42Z</dc:date>
    </item>
    <item>
      <title>Re: Regex help - disregard everything after a match</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-help-disregard-everything-after-a-match/m-p/449843#M127375</link>
      <description>&lt;P&gt;Thx &lt;/P&gt;

&lt;P&gt;I tried \w+ (&lt;A href="https://regex101.com/r/nInHIF/1"&gt;https://regex101.com/r/nInHIF/1&lt;/A&gt;) but still matches everything after blah.edu:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;blah.edu","Status":"Delivered","Size":"0"}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 26 Jun 2019 14:49:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-help-disregard-everything-after-a-match/m-p/449843#M127375</guid>
      <dc:creator>jwalzerpitt</dc:creator>
      <dc:date>2019-06-26T14:49:22Z</dc:date>
    </item>
    <item>
      <title>Re: Regex help - disregard everything after a match</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-help-disregard-everything-after-a-match/m-p/449844#M127376</link>
      <description>&lt;P&gt;Hi jwalzerpitt,&lt;BR /&gt;
try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;SenderAddress\":\"(?P&amp;lt;s_domain&amp;gt;[^\"]*).*RecipientAddress\":\"(?P&amp;lt;r_domain&amp;gt;[^\"]*)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can test it at &lt;A href="https://regex101.com/r/H3sxjR/1"&gt;https://regex101.com/r/H3sxjR/1&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2019 14:52:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-help-disregard-everything-after-a-match/m-p/449844#M127376</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-06-26T14:52:23Z</dc:date>
    </item>
    <item>
      <title>Re: Regex help - disregard everything after a match</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-help-disregard-everything-after-a-match/m-p/449845#M127377</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/103102"&gt;@jwalzerpitt&lt;/a&gt; ,&lt;BR /&gt;
You just need to anchor your regex properly.&lt;/P&gt;

&lt;P&gt;Try the following:&lt;BR /&gt;
&lt;PRE&gt;"SenderAddress":"[^@]+@(?&amp;lt;s_domain&amp;gt;[^"]+)","RecipientAddress":"[^@]+@(?&amp;lt;r_domain&amp;gt;[^"]+)"&lt;/PRE&gt;&lt;/P&gt;

&lt;P&gt;If you're using rex, you'll have to escape the double quotes:&lt;BR /&gt;
&lt;PRE&gt;| rex "\"SenderAddress\":\"[^@]+@(?&amp;lt;s_domain&amp;gt;[^\"]+)\",\"RecipientAddress\":\"[^@]+@(?&amp;lt;r_domain&amp;gt;[^\"]+)\""&lt;/PRE&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:03:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-help-disregard-everything-after-a-match/m-p/449845#M127377</guid>
      <dc:creator>jnudell_2</dc:creator>
      <dc:date>2020-09-30T01:03:47Z</dc:date>
    </item>
    <item>
      <title>Re: Regex help - disregard everything after a match</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-help-disregard-everything-after-a-match/m-p/449846#M127378</link>
      <description>&lt;P&gt;Guiseppe,&lt;/P&gt;

&lt;P&gt;Thx as that regex worked! Greatly appreciated&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2019 15:43:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-help-disregard-everything-after-a-match/m-p/449846#M127378</guid>
      <dc:creator>jwalzerpitt</dc:creator>
      <dc:date>2019-06-26T15:43:40Z</dc:date>
    </item>
    <item>
      <title>Re: Regex help - disregard everything after a match</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-help-disregard-everything-after-a-match/m-p/449847#M127379</link>
      <description>&lt;P&gt;Please convert it to an answer when you get a chance&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2019 15:44:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-help-disregard-everything-after-a-match/m-p/449847#M127379</guid>
      <dc:creator>jwalzerpitt</dc:creator>
      <dc:date>2019-06-26T15:44:26Z</dc:date>
    </item>
    <item>
      <title>Re: Regex help - disregard everything after a match</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-help-disregard-everything-after-a-match/m-p/449848#M127380</link>
      <description>&lt;P&gt;Thx for the reply and the regex/rex and they both worked as well. Much appreciated&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2019 15:45:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-help-disregard-everything-after-a-match/m-p/449848#M127380</guid>
      <dc:creator>jwalzerpitt</dc:creator>
      <dc:date>2019-06-26T15:45:25Z</dc:date>
    </item>
    <item>
      <title>Re: Regex help - disregard everything after a match</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-help-disregard-everything-after-a-match/m-p/449849#M127381</link>
      <description>&lt;P&gt;While that regex works, it might not be the best practice for regex usage.  Please review my answer above to see a better alternative for what you're trying to do with regex.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2019 16:55:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-help-disregard-everything-after-a-match/m-p/449849#M127381</guid>
      <dc:creator>jnudell_2</dc:creator>
      <dc:date>2019-06-26T16:55:13Z</dc:date>
    </item>
    <item>
      <title>Re: Regex help - disregard everything after a match</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-help-disregard-everything-after-a-match/m-p/449850#M127382</link>
      <description>&lt;P&gt;After further testing, I did apply the regex you recommended&lt;/P&gt;

&lt;P&gt;Thx&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2019 17:01:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-help-disregard-everything-after-a-match/m-p/449850#M127382</guid>
      <dc:creator>jwalzerpitt</dc:creator>
      <dc:date>2019-06-26T17:01:45Z</dc:date>
    </item>
  </channel>
</rss>

