<?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: regex - everything after last slash in Splunk Enterprise Security</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/regex-everything-after-last-slash/m-p/466175#M6966</link>
    <description>&lt;P&gt;these run:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal | head 100 | rex field=source "(?&amp;lt;filename&amp;gt;\w+\.\w+)$"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal | head 100 | rex field=source "\\\(?&amp;lt;filename&amp;gt;\w+\.\w+)$"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
    <pubDate>Mon, 16 Dec 2019 12:13:20 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2019-12-16T12:13:20Z</dc:date>
    <item>
      <title>regex - everything after last slash</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/regex-everything-after-last-slash/m-p/466165#M6956</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;How do I write a regex to capture everything after the final \ of a file name and search for within the query?&lt;/P&gt;

&lt;P&gt;i.e. \wtf\test\thisbithere.exe&lt;/P&gt;

&lt;P&gt;This works on regexe101:&lt;/P&gt;

&lt;P&gt;([^\]+$)&lt;/P&gt;

&lt;P&gt;But trying to use inline via the following keeps failing;&lt;/P&gt;

&lt;P&gt;| rex field=_raw "(?([^\]+$)"&lt;/P&gt;

&lt;P&gt;any ideas?&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 11:34:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/regex-everything-after-last-slash/m-p/466165#M6956</guid>
      <dc:creator>jacqu3sy</dc:creator>
      <dc:date>2019-12-16T11:34:04Z</dc:date>
    </item>
    <item>
      <title>Re: regex - everything after last slash</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/regex-everything-after-last-slash/m-p/466166#M6957</link>
      <description>&lt;P&gt;Hi @jacqu3sy,&lt;BR /&gt;
try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "\\(?&amp;lt;filename&amp;gt;\w+\.\w+)$"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;that you can test at &lt;A href="https://regex101.com/r/78fp97/1"&gt;https://regex101.com/r/78fp97/1&lt;/A&gt; .&lt;/P&gt;

&lt;P&gt;Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 11:41:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/regex-everything-after-last-slash/m-p/466166#M6957</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-12-16T11:41:31Z</dc:date>
    </item>
    <item>
      <title>Re: regex - everything after last slash</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/regex-everything-after-last-slash/m-p/466167#M6958</link>
      <description>&lt;P&gt;hmmm, errors when I run that in Splunk though?&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 11:49:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/regex-everything-after-last-slash/m-p/466167#M6958</guid>
      <dc:creator>jacqu3sy</dc:creator>
      <dc:date>2019-12-16T11:49:08Z</dc:date>
    </item>
    <item>
      <title>Re: regex - everything after last slash</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/regex-everything-after-last-slash/m-p/466168#M6959</link>
      <description>&lt;P&gt;Hi @jacqu3sy,&lt;BR /&gt;
what's error?&lt;/P&gt;

&lt;P&gt;have you used my regex in a search or in a dashboard?&lt;BR /&gt;
in a search it should run;&lt;BR /&gt;
if you're using in a dashboard you have to modify the regex because the Splunk editor has some problem:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "\\(?&amp;amp;lt;filename&amp;amp;gt;\w+\.\w+)$"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 11:53:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/regex-everything-after-last-slash/m-p/466168#M6959</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-12-16T11:53:56Z</dc:date>
    </item>
    <item>
      <title>Re: regex - everything after last slash</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/regex-everything-after-last-slash/m-p/466169#M6960</link>
      <description>&lt;P&gt;| rex "\(?\w+.\w+)$"&lt;/P&gt;

&lt;P&gt;Error in 'rex' command: Encountered the following error while compiling the regex '(?\w+.\w+)$': Regex: unmatched closing parenthesis&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 11:56:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/regex-everything-after-last-slash/m-p/466169#M6960</guid>
      <dc:creator>jacqu3sy</dc:creator>
      <dc:date>2019-12-16T11:56:24Z</dc:date>
    </item>
    <item>
      <title>Re: regex - everything after last slash</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/regex-everything-after-last-slash/m-p/466170#M6961</link>
      <description>&lt;P&gt;just straight from within a search&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 11:56:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/regex-everything-after-last-slash/m-p/466170#M6961</guid>
      <dc:creator>jacqu3sy</dc:creator>
      <dc:date>2019-12-16T11:56:51Z</dc:date>
    </item>
    <item>
      <title>Re: regex - everything after last slash</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/regex-everything-after-last-slash/m-p/466171#M6962</link>
      <description>&lt;P&gt;Hi @jacqu3sy,&lt;BR /&gt;
you have to use two backslashes in the beginning of the regex, not one!&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | rex "\\(?&amp;lt;filename&amp;gt;\w+\.\w+)$"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;P.S.: &lt;BR /&gt;
When you have to use a regex in a message, please, use the Code Sample button (101010), otherwise it's difficoult to read your messages.&lt;/P&gt;

&lt;P&gt;Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 12:01:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/regex-everything-after-last-slash/m-p/466171#M6962</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-12-16T12:01:55Z</dc:date>
    </item>
    <item>
      <title>Re: regex - everything after last slash</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/regex-everything-after-last-slash/m-p/466172#M6963</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval temp=" \wtf\test\thisbithere.exe" 
| rex field=temp "(?P&amp;lt;filename&amp;gt;[^\\\]+)$" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval temp="\wtf\test\thisbithere.exe" 
|eval filename =mvindex(split(temp,"\\"),-1)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Dec 2019 12:03:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/regex-everything-after-last-slash/m-p/466172#M6963</guid>
      <dc:creator>vnravikumar</dc:creator>
      <dc:date>2019-12-16T12:03:34Z</dc:date>
    </item>
    <item>
      <title>Re: regex - everything after last slash</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/regex-everything-after-last-slash/m-p/466173#M6964</link>
      <description>&lt;P&gt;Yeh, even with the second backslash I get an error when running straight from a search query, related to 'unmatched closing parenthesis'&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;mysearch&amp;gt;
| rex "\\(?&amp;lt;filename&amp;gt;\w+\.\w+)$"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Dec 2019 12:06:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/regex-everything-after-last-slash/m-p/466173#M6964</guid>
      <dc:creator>jacqu3sy</dc:creator>
      <dc:date>2019-12-16T12:06:25Z</dc:date>
    </item>
    <item>
      <title>Re: regex - everything after last slash</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/regex-everything-after-last-slash/m-p/466174#M6965</link>
      <description>&lt;P&gt;Try my answer&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 12:12:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/regex-everything-after-last-slash/m-p/466174#M6965</guid>
      <dc:creator>vnravikumar</dc:creator>
      <dc:date>2019-12-16T12:12:31Z</dc:date>
    </item>
    <item>
      <title>Re: regex - everything after last slash</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/regex-everything-after-last-slash/m-p/466175#M6966</link>
      <description>&lt;P&gt;these run:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal | head 100 | rex field=source "(?&amp;lt;filename&amp;gt;\w+\.\w+)$"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal | head 100 | rex field=source "\\\(?&amp;lt;filename&amp;gt;\w+\.\w+)$"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 12:13:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/regex-everything-after-last-slash/m-p/466175#M6966</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-12-16T12:13:20Z</dc:date>
    </item>
    <item>
      <title>Re: regex - everything after last slash</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/regex-everything-after-last-slash/m-p/466176#M6967</link>
      <description>&lt;P&gt;This works as well, leveraging positive lookbehind:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex "(?&amp;lt;=\\)(?&amp;lt;theWord&amp;gt;[\w\.]+)$"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Regex101: &lt;A href="https://regex101.com/r/eslxJR/2"&gt;https://regex101.com/r/eslxJR/2&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 12:46:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/regex-everything-after-last-slash/m-p/466176#M6967</guid>
      <dc:creator>jpolvino</dc:creator>
      <dc:date>2019-12-16T12:46:43Z</dc:date>
    </item>
    <item>
      <title>Re: regex - everything after last slash</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/regex-everything-after-last-slash/m-p/466177#M6968</link>
      <description>&lt;P&gt;appreciate the efforts, really do. Unfortunatly I couldnt get these to work, but thanks anyway.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 12:55:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/regex-everything-after-last-slash/m-p/466177#M6968</guid>
      <dc:creator>jacqu3sy</dc:creator>
      <dc:date>2019-12-16T12:55:07Z</dc:date>
    </item>
    <item>
      <title>Re: regex - everything after last slash</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/regex-everything-after-last-slash/m-p/466178#M6969</link>
      <description>&lt;P&gt;Both these worked, many thanks, much appreciated.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 12:55:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/regex-everything-after-last-slash/m-p/466178#M6969</guid>
      <dc:creator>jacqu3sy</dc:creator>
      <dc:date>2019-12-16T12:55:33Z</dc:date>
    </item>
  </channel>
</rss>

