<?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: Help with a regex (extract the file name from the file path) in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Help-with-a-regex-extract-the-file-name-from-the-file-path/m-p/548672#M91206</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/223017"&gt;@kvnpichon&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Please try below in your props;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;props.conf
REPORT-file_name=file_name_extract

transforms.conf
[file_name_extract]
SOURCE_KEY= filePath
REGEX= "\\\\(?&amp;lt;file_name&amp;gt;[A-Za-z0-9\._\[\]-]+\.(?:exe|zip))(?:\s|\()"
FORMAT = file_name::$1&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 20 Apr 2021 19:42:22 GMT</pubDate>
    <dc:creator>scelikok</dc:creator>
    <dc:date>2021-04-20T19:42:22Z</dc:date>
    <item>
      <title>Help with a regex (extract the file name from the file path)</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Help-with-a-regex-extract-the-file-name-from-the-file-path/m-p/548208#M91174</link>
      <description>&lt;P&gt;Hi Splunkers,&lt;/P&gt;&lt;P&gt;I need some help with a regex/command to extract the file name from the file path :&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;EM&gt;path\\to\\the\\file\\&lt;STRONG&gt;file_name&lt;/STRONG&gt;&lt;/EM&gt;&lt;/LI&gt;&lt;LI&gt;or &lt;EM&gt;path\\to\\the\\file\\&lt;STRONG&gt;file_name &lt;/STRONG&gt;(path\\inside\\file)&lt;/EM&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Actually I have the EVAL command in my props.conf :&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;EM&gt;EVAL-file_name = mvindex(split(filePath,"\\"),-1)&lt;/EM&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;The EVAL command working fine for most of the paths. But sometimes, the path is not common and contains&amp;nbsp; parentheses and backslashs after the file_name value...&lt;/P&gt;&lt;P&gt;This is some examples of unusual paths I encountered (what I want to extract is in bold) :&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;T:\\test\\&lt;STRONG&gt;FileZilla_3.47.2.1_win64_sponsored-setup.exe&lt;/STRONG&gt; (NONAMEFL)&lt;/LI&gt;&lt;LI&gt;C:\\Users\\testuser\\Desktop\\testuser\\Local Settings\\Temporary Internet Files\\Content.IE5\\test\\&lt;STRONG&gt;ocspackage[1].exe&lt;/STRONG&gt;($PLUGINSDIR\\$PLUGINSDIR\\RemCom.exe)&lt;/LI&gt;&lt;LI&gt;C:\\TEST\\testing\\@Archives\\@SRV\\SRV_Servers\\tests\\ocs-inventory\\&lt;STRONG&gt;OCSNG_AGENT_DEPLOYMENT_TOOL_1.0.1.2.zip&lt;/STRONG&gt; ($INSTDIR\\RemCom.exe)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;With my actual configuration I extract only the value after the last "\\" of the line...&lt;/P&gt;&lt;P&gt;Could you help me to construct that regex/command to be able to exctract the right values ?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 13:30:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Help-with-a-regex-extract-the-file-name-from-the-file-path/m-p/548208#M91174</guid>
      <dc:creator>kvnpichon</dc:creator>
      <dc:date>2021-04-16T13:30:02Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a regex (extract the file name from the file path)</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Help-with-a-regex-extract-the-file-name-from-the-file-path/m-p/548229#M91176</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;trim(mvindex(split(mvindex(split(filePath,"("),0),"\\"),-1))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 14:50:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Help-with-a-regex-extract-the-file-name-from-the-file-path/m-p/548229#M91176</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-04-16T14:50:52Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a regex (extract the file name from the file path)</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Help-with-a-regex-extract-the-file-name-from-the-file-path/m-p/548400#M91183</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to add your line in my props.conf file but the file_name isn't extracted as expected.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Apr 2021 08:56:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Help-with-a-regex-extract-the-file-name-from-the-file-path/m-p/548400#M91183</guid>
      <dc:creator>kvnpichon</dc:creator>
      <dc:date>2021-04-19T08:56:01Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a regex (extract the file name from the file path)</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Help-with-a-regex-extract-the-file-name-from-the-file-path/m-p/548672#M91206</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/223017"&gt;@kvnpichon&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Please try below in your props;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;props.conf
REPORT-file_name=file_name_extract

transforms.conf
[file_name_extract]
SOURCE_KEY= filePath
REGEX= "\\\\(?&amp;lt;file_name&amp;gt;[A-Za-z0-9\._\[\]-]+\.(?:exe|zip))(?:\s|\()"
FORMAT = file_name::$1&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 20 Apr 2021 19:42:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Help-with-a-regex-extract-the-file-name-from-the-file-path/m-p/548672#M91206</guid>
      <dc:creator>scelikok</dc:creator>
      <dc:date>2021-04-20T19:42:22Z</dc:date>
    </item>
  </channel>
</rss>

