<?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: What rex can I use to extract a value before a string near the end of an event? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/What-rex-can-I-use-to-extract-a-value-before-a-string-near-the/m-p/446624#M126691</link>
    <description>&lt;P&gt;Hi octavioserpa,&lt;/P&gt;

&lt;P&gt;please remove all IP's or email address before you post log samples &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;

&lt;P&gt;PS: I removed them from this post &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 26 Oct 2018 08:52:17 GMT</pubDate>
    <dc:creator>MuS</dc:creator>
    <dc:date>2018-10-26T08:52:17Z</dc:date>
    <item>
      <title>What rex can I use to extract a value before a string near the end of an event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-rex-can-I-use-to-extract-a-value-before-a-string-near-the/m-p/446623#M126690</link>
      <description>&lt;P&gt;I need to extract the value where "SoftFail" from this example log is.&lt;/P&gt;

&lt;P&gt;In related logs, the value is always after an email address, and before (v=spf1). The value always has one space before it. At first glance, looking for a value after email address seems like it could work, but there are many domain possibilities, including those with subdomains so it's hard to use rex based on @ and x amount of .'s)&lt;/P&gt;

&lt;P&gt;Is there away to capture like the following?:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;start at end of line&lt;/LI&gt;
&lt;LI&gt;work backwards to space before (v=spf1), capture the value as SPF_Result field, stop at the first space before the value&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;Oct 25 21:16:05 x.x.x.x Splunk_PIApp_MailLogs_QDC: Info: MID 92041462 SPF: mailfrom identity &lt;A href="mailto:foo@bar.com" target="_blank"&gt;foo@bar.com&lt;/A&gt; SoftFail (v=spf1) &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:45:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-rex-can-I-use-to-extract-a-value-before-a-string-near-the/m-p/446623#M126690</guid>
      <dc:creator>octavioserpa</dc:creator>
      <dc:date>2020-09-29T21:45:42Z</dc:date>
    </item>
    <item>
      <title>Re: What rex can I use to extract a value before a string near the end of an event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-rex-can-I-use-to-extract-a-value-before-a-string-near-the/m-p/446624#M126691</link>
      <description>&lt;P&gt;Hi octavioserpa,&lt;/P&gt;

&lt;P&gt;please remove all IP's or email address before you post log samples &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;

&lt;P&gt;PS: I removed them from this post &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Oct 2018 08:52:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-rex-can-I-use-to-extract-a-value-before-a-string-near-the/m-p/446624#M126691</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2018-10-26T08:52:17Z</dc:date>
    </item>
    <item>
      <title>Re: What rex can I use to extract a value before a string near the end of an event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-rex-can-I-use-to-extract-a-value-before-a-string-near-the/m-p/446625#M126692</link>
      <description>&lt;P&gt;@octavioserpa,&lt;/P&gt;

&lt;P&gt;Try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|rex field=_raw ".*\s(?&amp;lt;SPF_Result&amp;gt;\w+)\s\(v=spf1\)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OR&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|rex field=_raw "(?&amp;lt;SPF_Result&amp;gt;\w+)\s\(v=spf1\)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Second one is bit expensive &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Oct 2018 09:39:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-rex-can-I-use-to-extract-a-value-before-a-string-near-the/m-p/446625#M126692</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2018-10-26T09:39:54Z</dc:date>
    </item>
    <item>
      <title>Re: What rex can I use to extract a value before a string near the end of an event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-rex-can-I-use-to-extract-a-value-before-a-string-near-the/m-p/446626#M126693</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval log="Oct 25 21:16:05 x.x.x.x Splunk_PIApp_MailLogs_QDC: Info: MID 92041462 SPF: mailfrom identity foo@bar.com SoftFail (v=spf1)" 
| rex field=log "(?P&amp;lt;mailid&amp;gt;\w+\@\w+\.\w+) SoftFail"
| table log mailid
&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/5990i10B8CD33DE4A158E/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>Fri, 26 Oct 2018 12:07:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-rex-can-I-use-to-extract-a-value-before-a-string-near-the/m-p/446626#M126693</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2018-10-26T12:07:45Z</dc:date>
    </item>
    <item>
      <title>Re: What rex can I use to extract a value before a string near the end of an event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-rex-can-I-use-to-extract-a-value-before-a-string-near-the/m-p/446627#M126694</link>
      <description>&lt;P&gt;This will work:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\S@[^\s]+\s+(?&amp;lt;SPF_RESULT&amp;gt;[^ ]+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;See it in action here: &lt;A href="https://regex101.com/r/zzf5RJ/1"&gt;https://regex101.com/r/zzf5RJ/1&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Oct 2018 19:08:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-rex-can-I-use-to-extract-a-value-before-a-string-near-the/m-p/446627#M126694</guid>
      <dc:creator>wrangler2x</dc:creator>
      <dc:date>2018-10-26T19:08:01Z</dc:date>
    </item>
    <item>
      <title>Re: What rex can I use to extract a value before a string near the end of an event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-rex-can-I-use-to-extract-a-value-before-a-string-near-the/m-p/446628#M126695</link>
      <description>&lt;P&gt;@octavioserpa, if any of the answers helped you , please accept /upvote or comment here if you need further assistance&lt;/P&gt;</description>
      <pubDate>Tue, 30 Oct 2018 06:05:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-rex-can-I-use-to-extract-a-value-before-a-string-near-the/m-p/446628#M126695</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2018-10-30T06:05:11Z</dc:date>
    </item>
  </channel>
</rss>

