<?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 create a regex to match URL ending with file extension to detect file downloads? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-match-URL-ending-with-file-extension-to/m-p/431310#M123286</link>
    <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... |regex url="^https?:\/\/.*[\\\/].+\.[a-zA-Z]{2,4}$"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 24 Jun 2019 01:21:58 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2019-06-24T01:21:58Z</dc:date>
    <item>
      <title>How to create a regex to match URL ending with file extension to detect file downloads?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-match-URL-ending-with-file-extension-to/m-p/431307#M123283</link>
      <description>&lt;P&gt;I am trying to write a regex which will detect/match URLs ending with 2, 3 &amp;amp; 4 letter file extensions (eg - .py, .txt, xlsx and the numerous other known file extensions) . I used the regex Splunk search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|regex field url=".*[a-zA-Z]{2-4}$"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but this will match URLs like &lt;A href="http://www.liverpoolfc.com"&gt;www.liverpoolfc.com&lt;/A&gt; which does not end with file extensions. &lt;/P&gt;

&lt;P&gt;Also tried with this regex: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| regex url="//.+?/.+?.$" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Which will look for the http: or https: then two "/" followed by the top level domain and one "/" followed by any stream of character and ending with 2 to 4 letter word, but this is not giving the correct results, its omitting few URLs which have multiple "/" in the full URL path, any better suggestions ?&lt;/P&gt;

&lt;P&gt;Below is a sample set of URLs that I used as a reference:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&lt;A href="http://www.liverpoolfc.com" target="test_blank"&gt;http://www.liverpoolfc.com&lt;/A&gt;
&lt;A href="http://www.blackberry.com" target="test_blank"&gt;http://www.blackberry.com&lt;/A&gt;
&lt;A href="http://www.lflogistics.com/sites/default/files/news/lflstc.pdf" target="test_blank"&gt;http://www.lflogistics.com/sites/default/files/news/lflstc.pdf&lt;/A&gt;
&lt;A href="https://www.abc.com/tiny/7uwi2" target="test_blank"&gt;https://www.abc.com/tiny/7uwi2&lt;/A&gt;
&lt;A href="https://download.abc.com/download/ep/FE-90CRC000-28.zip" target="test_blank"&gt;https://download.abc.com/download/ep/FE-90CRC000-28.zip&lt;/A&gt;
&lt;A href="http://www3.abce.hk/listedco/listconews/SEHK/2019/0521/LTN20190521894.pdf" target="test_blank"&gt;http://www3.abce.hk/listedco/listconews/SEHK/2019/0521/LTN20190521894.pdf&lt;/A&gt;
&lt;A href="https://www.abc.com/review/www.xyz-center.com" target="test_blank"&gt;https://www.abc.com/review/www.xyz-center.com&lt;/A&gt;
&lt;A href="https://xyz.abc.com/abc-voyager.php" target="test_blank"&gt;https://xyz.abc.com/abc-voyager.php&lt;/A&gt;
&lt;A href="http://wealthbriefing.com/forms/view.php?id=1456762⪙ement_34=saint.xyz@gmail.com" target="test_blank"&gt;http://wealthbriefing.com/forms/view.php?id=1456762⪙ement_34=saint.xyz@gmail.com&lt;/A&gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Jun 2019 09:29:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-match-URL-ending-with-file-extension-to/m-p/431307#M123283</guid>
      <dc:creator>jkumarr2</dc:creator>
      <dc:date>2019-06-21T09:29:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regex to match URL ending with file extension to detect file downloads?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-match-URL-ending-with-file-extension-to/m-p/431308#M123284</link>
      <description>&lt;P&gt;Hi jkumarr2,&lt;BR /&gt;
try this one&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?P&amp;lt;URL&amp;gt;[^ ]*\.\w*)$
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can test it at &lt;A href="https://regex101.com/r/2syl1Z/1"&gt;https://regex101.com/r/2syl1Z/1&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jun 2019 12:51:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-match-URL-ending-with-file-extension-to/m-p/431308#M123284</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-06-21T12:51:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regex to match URL ending with file extension to detect file downloads?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-match-URL-ending-with-file-extension-to/m-p/431309#M123285</link>
      <description>&lt;P&gt;Hi @jkumarr2 ,&lt;/P&gt;

&lt;P&gt;I would use something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... your search ...
| regex url="(https?:\/\/)?([A-Za-z0-9\-]+)?\.([A-Za-z0-9\-]+)\.([A-Za-z0-9\-]+)(\/?.*\/(.+\.[A-Za-z]{2,3})$)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or maybe:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... your search ...
| regex url=".*\/\/[^\/]+\/?.*\/.*\.[A-Za-z]{2,3}"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Jun 2019 19:10:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-match-URL-ending-with-file-extension-to/m-p/431309#M123285</guid>
      <dc:creator>jnudell_2</dc:creator>
      <dc:date>2019-06-21T19:10:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regex to match URL ending with file extension to detect file downloads?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-match-URL-ending-with-file-extension-to/m-p/431310#M123286</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... |regex url="^https?:\/\/.*[\\\/].+\.[a-zA-Z]{2,4}$"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Jun 2019 01:21:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-match-URL-ending-with-file-extension-to/m-p/431310#M123286</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-06-24T01:21:58Z</dc:date>
    </item>
  </channel>
</rss>

