<?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: Extracting File Type in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Extracting-File-Type/m-p/25251#M177560</link>
    <description>&lt;P&gt;Thanks,&lt;/P&gt;

&lt;P&gt;When I try and use the rex I get the following error (havent really used rex): "Error in 'rex' command: The regex '([^.]+)$' does not extract anything. It should specify at least one named group. Format: (?&lt;NAME&gt;...)."&lt;/NAME&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 06 May 2013 15:22:30 GMT</pubDate>
    <dc:creator>behymejt2012</dc:creator>
    <dc:date>2013-05-06T15:22:30Z</dc:date>
    <item>
      <title>Extracting File Type</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-File-Type/m-p/25249#M177558</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;

&lt;P&gt;Trying to extract the File Type from Files (ex: pst, xml, etc). I have tried to split it:&lt;/P&gt;

&lt;P&gt;eval split =Split(File,".") | eval type=mvindex(split,1)&lt;/P&gt;

&lt;P&gt;But a problem occurs when files like: "2012-12-08 15.36.01.jpg" show up due to the extra "." in the file name.&lt;/P&gt;

&lt;P&gt;Is there any recommended rex, or method that can be used to pull the file type from the end of the File name instead of trying to split everything up.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 06 May 2013 13:56:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-File-Type/m-p/25249#M177558</guid>
      <dc:creator>behymejt2012</dc:creator>
      <dc:date>2013-05-06T13:56:02Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting File Type</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-File-Type/m-p/25250#M177559</link>
      <description>&lt;P&gt;If you read the docs, they have the following to say about the mvindex command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;For mvindex(mvfield, startindex, [endindex]), endindex is inclusive and optional; both startindex and endindex can be negative, where -1 is the last element.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So, &lt;CODE&gt;eval type=mvindex(split,-1)&lt;/CODE&gt; should do the trick.&lt;/P&gt;

&lt;P&gt;Otherwise, if you want a &lt;CODE&gt;rex&lt;/CODE&gt; solution, you could do&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field=File "(?&amp;lt;type&amp;gt;[^.]+)$"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 May 2013 14:09:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-File-Type/m-p/25250#M177559</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2013-05-06T14:09:42Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting File Type</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-File-Type/m-p/25251#M177560</link>
      <description>&lt;P&gt;Thanks,&lt;/P&gt;

&lt;P&gt;When I try and use the rex I get the following error (havent really used rex): "Error in 'rex' command: The regex '([^.]+)$' does not extract anything. It should specify at least one named group. Format: (?&lt;NAME&gt;...)."&lt;/NAME&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 May 2013 15:22:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-File-Type/m-p/25251#M177560</guid>
      <dc:creator>behymejt2012</dc:creator>
      <dc:date>2013-05-06T15:22:30Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting File Type</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-File-Type/m-p/25252#M177561</link>
      <description>&lt;P&gt;Sorry, like it says - you need to include a group name at the beginning. I updated my answer with correct syntax.&lt;/P&gt;</description>
      <pubDate>Mon, 06 May 2013 20:53:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-File-Type/m-p/25252#M177561</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2013-05-06T20:53:08Z</dc:date>
    </item>
  </channel>
</rss>

