<?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: First match from end of the line regex in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/First-match-from-end-of-the-line-regex/m-p/291182#M87969</link>
    <description>&lt;P&gt;Hey subtrakt,&lt;/P&gt;

&lt;P&gt;try this one:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;(?i).*(?&amp;lt;testfromend&amp;gt;(Facility\=|Message\=)[^$]*?)$&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Update: even better:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;(?i)(?&amp;lt;testfromend&amp;gt;(Facility\=|Message\=)[^\=]*?)$&lt;/CODE&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 19 Feb 2018 19:58:45 GMT</pubDate>
    <dc:creator>bjoernhansen</dc:creator>
    <dc:date>2018-02-19T19:58:45Z</dc:date>
    <item>
      <title>First match from end of the line regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/First-match-from-end-of-the-line-regex/m-p/291180#M87967</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;

&lt;P&gt;Trying to get the expression to read first match from the end off the line and not the beginning of the line.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval TEST="beginning of line Facility=test341 Message=test123 end of line" | rex field=TEST max_match=0 "(?i)(?&amp;lt;testfromend&amp;gt;(Facility\=|Message\=)[^$]*)" | mvcombine testfromend
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Was hoping this would extract "Message=test123 end of line".  Instead i get Facility= and everything after because its reading from the beginning of the line still.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Feb 2018 19:33:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/First-match-from-end-of-the-line-regex/m-p/291180#M87967</guid>
      <dc:creator>subtrakt</dc:creator>
      <dc:date>2018-02-19T19:33:28Z</dc:date>
    </item>
    <item>
      <title>Re: First match from end of the line regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/First-match-from-end-of-the-line-regex/m-p/291181#M87968</link>
      <description>&lt;P&gt;Hey subtrakt, &lt;/P&gt;

&lt;P&gt;why not use &lt;CODE&gt;(?i)(?&amp;lt;testfromend&amp;gt;Message\=[^$]*)&lt;/CODE&gt; then?&lt;/P&gt;

&lt;P&gt;BUT... if you want to extract the value of facility and of message do the following:&lt;BR /&gt;
&lt;CODE&gt;(?i)Facility=(?&amp;lt;facility&amp;gt;[^\s]*)\s*Message=(?&amp;lt;message&amp;gt;.*)&lt;/CODE&gt;&lt;BR /&gt;
&lt;A href="https://regex101.com/r/DGZX5X/1"&gt;https://regex101.com/r/DGZX5X/1&lt;/A&gt; &lt;/P&gt;</description>
      <pubDate>Mon, 19 Feb 2018 19:56:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/First-match-from-end-of-the-line-regex/m-p/291181#M87968</guid>
      <dc:creator>horsefez</dc:creator>
      <dc:date>2018-02-19T19:56:31Z</dc:date>
    </item>
    <item>
      <title>Re: First match from end of the line regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/First-match-from-end-of-the-line-regex/m-p/291182#M87969</link>
      <description>&lt;P&gt;Hey subtrakt,&lt;/P&gt;

&lt;P&gt;try this one:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;(?i).*(?&amp;lt;testfromend&amp;gt;(Facility\=|Message\=)[^$]*?)$&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Update: even better:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;(?i)(?&amp;lt;testfromend&amp;gt;(Facility\=|Message\=)[^\=]*?)$&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Feb 2018 19:58:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/First-match-from-end-of-the-line-regex/m-p/291182#M87969</guid>
      <dc:creator>bjoernhansen</dc:creator>
      <dc:date>2018-02-19T19:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: First match from end of the line regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/First-match-from-end-of-the-line-regex/m-p/291183#M87970</link>
      <description>&lt;P&gt;Thanks Pyro.&lt;BR /&gt;&lt;BR /&gt;
Just experimenting without using eval and creating unnecessary fields. The condition requires message to always take precedence. &lt;/P&gt;

&lt;P&gt;Sometimes Message= is not in the log.  Sometimes it is.  When message is not in the log, it needs to capture Facilility to end of line.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Feb 2018 20:10:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/First-match-from-end-of-the-line-regex/m-p/291183#M87970</guid>
      <dc:creator>subtrakt</dc:creator>
      <dc:date>2018-02-19T20:10:36Z</dc:date>
    </item>
    <item>
      <title>Re: First match from end of the line regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/First-match-from-end-of-the-line-regex/m-p/291184#M87971</link>
      <description>&lt;P&gt;I ended up using the first solution.  &lt;/P&gt;

&lt;P&gt;I guess the .* enables the search from end of line and a more flexible option.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Feb 2018 23:28:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/First-match-from-end-of-the-line-regex/m-p/291184#M87971</guid>
      <dc:creator>subtrakt</dc:creator>
      <dc:date>2018-02-19T23:28:33Z</dc:date>
    </item>
    <item>
      <title>Re: First match from end of the line regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/First-match-from-end-of-the-line-regex/m-p/291185#M87972</link>
      <description>&lt;P&gt;There's other cases in the logs that require different conditions searching from the end of the line.  &lt;/P&gt;

&lt;P&gt;After testing around all those conditions I found the answer selected was the best global option. &lt;/P&gt;</description>
      <pubDate>Tue, 20 Feb 2018 00:25:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/First-match-from-end-of-the-line-regex/m-p/291185#M87972</guid>
      <dc:creator>subtrakt</dc:creator>
      <dc:date>2018-02-20T00:25:06Z</dc:date>
    </item>
  </channel>
</rss>

