<?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 How do I extract  last two fields of a string separated by a delimiter? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-last-two-fields-of-a-string-separated-by-a/m-p/253131#M175838</link>
    <description>&lt;P&gt;Hi- I have some strings separated by "." delimiter.  For example, &lt;BR /&gt;
a.b.c.d&lt;BR /&gt;
x.y.z&lt;BR /&gt;
p.q.r.s.t.u&lt;/P&gt;

&lt;P&gt;I want to be able to extract the last two fields with the delimiter. So, I want my output to be:&lt;BR /&gt;
c.d&lt;BR /&gt;
y.z&lt;BR /&gt;
t.u&lt;/P&gt;

&lt;P&gt;Is there a method to perform such action?&lt;BR /&gt;
 Thanks,&lt;BR /&gt;
MA&lt;/P&gt;</description>
    <pubDate>Wed, 25 Jan 2017 14:00:44 GMT</pubDate>
    <dc:creator>masfar</dc:creator>
    <dc:date>2017-01-25T14:00:44Z</dc:date>
    <item>
      <title>How do I extract  last two fields of a string separated by a delimiter?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-last-two-fields-of-a-string-separated-by-a/m-p/253131#M175838</link>
      <description>&lt;P&gt;Hi- I have some strings separated by "." delimiter.  For example, &lt;BR /&gt;
a.b.c.d&lt;BR /&gt;
x.y.z&lt;BR /&gt;
p.q.r.s.t.u&lt;/P&gt;

&lt;P&gt;I want to be able to extract the last two fields with the delimiter. So, I want my output to be:&lt;BR /&gt;
c.d&lt;BR /&gt;
y.z&lt;BR /&gt;
t.u&lt;/P&gt;

&lt;P&gt;Is there a method to perform such action?&lt;BR /&gt;
 Thanks,&lt;BR /&gt;
MA&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2017 14:00:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-last-two-fields-of-a-string-separated-by-a/m-p/253131#M175838</guid>
      <dc:creator>masfar</dc:creator>
      <dc:date>2017-01-25T14:00:44Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract  last two fields of a string separated by a delimiter?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-last-two-fields-of-a-string-separated-by-a/m-p/253132#M175839</link>
      <description>&lt;P&gt;How about trying this, let's say your data is in field &lt;CODE&gt;myField&lt;/CODE&gt; which has strings like  &lt;CODE&gt;w.x.y.z&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your query to return events
| eval splitString=split(myField, ".")
| eval count=mvcount(splitString)
| eval requiredString=mvindex( splitString, count-2).".".mvindex(splitString, count-1)
| table requiredString
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Jan 2017 18:02:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-last-two-fields-of-a-string-separated-by-a/m-p/253132#M175839</guid>
      <dc:creator>gokadroid</dc:creator>
      <dc:date>2017-01-25T18:02:52Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract  last two fields of a string separated by a delimiter?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-last-two-fields-of-a-string-separated-by-a/m-p/253133#M175840</link>
      <description>&lt;P&gt;This can also work, saves the "eval count=mvcount(splitstring)" clause&lt;BR /&gt;
 | eval splitString=split(myField, ".")&lt;BR /&gt;
 | eval requiredString=mvindex(splitString, -2).".".mvindex(splitString, -1)&lt;BR /&gt;
 | table requiredString&lt;/P&gt;

&lt;P&gt;It appears the mvindex list can use negative indices to start from the end of the list.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2017 18:30:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-last-two-fields-of-a-string-separated-by-a/m-p/253133#M175840</guid>
      <dc:creator>anshu</dc:creator>
      <dc:date>2017-01-25T18:30:09Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract  last two fields of a string separated by a delimiter?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-last-two-fields-of-a-string-separated-by-a/m-p/253134#M175841</link>
      <description>&lt;P&gt;Thanks, that works!&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2017 20:28:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-last-two-fields-of-a-string-separated-by-a/m-p/253134#M175841</guid>
      <dc:creator>masfar</dc:creator>
      <dc:date>2017-01-25T20:28:56Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract  last two fields of a string separated by a delimiter?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-last-two-fields-of-a-string-separated-by-a/m-p/253135#M175842</link>
      <description>&lt;P&gt;An alternative command (rex). Assuming dot as delimiter. Regex might need updates based on type of values the string between delimiter contains.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | rex field=myField "\.(?&amp;lt;requiredString&amp;gt;\w+\.\w+)$" | table myField requiredString
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Jan 2017 20:35:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-last-two-fields-of-a-string-separated-by-a/m-p/253135#M175842</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-01-25T20:35:44Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract  last two fields of a string separated by a delimiter?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-last-two-fields-of-a-string-separated-by-a/m-p/253136#M175843</link>
      <description>&lt;P&gt;Building on somesoni2's expression, this would allow for any characters other than the delimiter: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | rex field=myField "\.(?&amp;lt;requiredString&amp;gt;[^.]+\.[^.]+)$" | table myField requiredString
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Jan 2017 20:54:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-last-two-fields-of-a-string-separated-by-a/m-p/253136#M175843</guid>
      <dc:creator>anshu</dc:creator>
      <dc:date>2017-01-25T20:54:22Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract  last two fields of a string separated by a delimiter?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-last-two-fields-of-a-string-separated-by-a/m-p/253137#M175844</link>
      <description>&lt;P&gt;Thanks, somesoni2!&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2017 20:26:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-last-two-fields-of-a-string-separated-by-a/m-p/253137#M175844</guid>
      <dc:creator>masfar</dc:creator>
      <dc:date>2017-01-26T20:26:46Z</dc:date>
    </item>
  </channel>
</rss>

