<?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: How to use regex/rex to extract filename from URI in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-rex-to-extract-filename-from-URI/m-p/277307#M83630</link>
    <description>&lt;P&gt;Hi woodcock,&lt;/P&gt;

&lt;P&gt;Thank you for you speedy reply. I tried copying and pasting your solution into splunk and it doesnt return any results. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| rex field=url ".^.*\/(?&amp;lt;filename&amp;gt;[^\.\/]+\.(?:[^\.\/]){3,4})$" | top filename
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any ideas on what I could be missing?&lt;/P&gt;</description>
    <pubDate>Wed, 06 Apr 2016 21:29:59 GMT</pubDate>
    <dc:creator>jmedved</dc:creator>
    <dc:date>2016-04-06T21:29:59Z</dc:date>
    <item>
      <title>How to use regex/rex to extract filename from URI</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-rex-to-extract-filename-from-URI/m-p/277305#M83628</link>
      <description>&lt;P&gt;I am looking for a way to extract filenames of executable files from a URL in proxy logs. The url field in my logs contain the full URL. Here are a few examples. I think we just need to capture everything past the last "/" if it contains 3 or 4 chars after the last ".". Has anyone done anything like this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;url=http://www.kaco.net/download/kacotv.exe
url=http://acroipm2.adobe.com/15/rdr/ENU/win/nooem/none/consumer/message.zip
url=https://prod308-client.redplum.com/protocol/install/P@H_prod308-1dF7CZ5x.exe
url=http://download.microsoft.com/download/5/3/D/53D3880B-25F8-4714-A4AC-E463A492F96E/41212.00/Silverlight_x64.exe
url=http://download.flv.com/kits/flvd/flvdownloader_setup.exe
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Apr 2016 20:51:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-rex-to-extract-filename-from-URI/m-p/277305#M83628</guid>
      <dc:creator>jmedved</dc:creator>
      <dc:date>2016-04-06T20:51:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to use regex/rex to extract filename from URI</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-rex-to-extract-filename-from-URI/m-p/277306#M83629</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field=url "^.*\/(?&amp;lt;programname&amp;gt;[^\.\/]+\.(?:[^\.\/]){3,4})$"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Apr 2016 21:00:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-rex-to-extract-filename-from-URI/m-p/277306#M83629</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-04-06T21:00:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to use regex/rex to extract filename from URI</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-rex-to-extract-filename-from-URI/m-p/277307#M83630</link>
      <description>&lt;P&gt;Hi woodcock,&lt;/P&gt;

&lt;P&gt;Thank you for you speedy reply. I tried copying and pasting your solution into splunk and it doesnt return any results. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| rex field=url ".^.*\/(?&amp;lt;filename&amp;gt;[^\.\/]+\.(?:[^\.\/]){3,4})$" | top filename
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any ideas on what I could be missing?&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2016 21:29:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-rex-to-extract-filename-from-URI/m-p/277307#M83630</guid>
      <dc:creator>jmedved</dc:creator>
      <dc:date>2016-04-06T21:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to use regex/rex to extract filename from URI</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-rex-to-extract-filename-from-URI/m-p/277308#M83631</link>
      <description>&lt;P&gt;Try this run anywhere sample. This is the regex that I use for any field extraction related to URL to extract other information as well&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 | eval url="http://www.kaco.net/download/kacotv.exe" | rex field=url "(?P&amp;lt;requestedUrl&amp;gt;(?P&amp;lt;path&amp;gt;\/(((?P&amp;lt;contextRoot&amp;gt;[^\/]+))(\S+\/)*(?P&amp;lt;filename&amp;gt;[^\/\?;=\s]+)([^\s]*))))" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Replace "| gentimes...| eval ulr..." portion with your base search.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2016 21:43:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-rex-to-extract-filename-from-URI/m-p/277308#M83631</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-04-06T21:43:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to use regex/rex to extract filename from URI</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-rex-to-extract-filename-from-URI/m-p/277309#M83632</link>
      <description>&lt;P&gt;There was an extra period (".") at the start of the RegEx.  I have fixed it; try again.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2016 21:44:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-rex-to-extract-filename-from-URI/m-p/277309#M83632</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-04-06T21:44:32Z</dc:date>
    </item>
  </channel>
</rss>

