<?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 the date from a filename without modifying the datetime.xml in Knowledge Management</title>
    <link>https://community.splunk.com/t5/Knowledge-Management/Extracting-the-date-from-a-filename-without-modifying-the/m-p/326003#M5679</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;Can you please try this query, it will extract date from your source file name in &lt;CODE&gt;date&lt;/CODE&gt; field.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="name_name_20171130.txt" host="xxx" |   rex field=source "(?:[^\_]*\_){2}(?&amp;lt;date&amp;gt;.*)\.txt" |table _raw, ITEM, SOH_DIFF, date
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I hope this helps.&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Harshil&lt;/P&gt;</description>
    <pubDate>Mon, 04 Dec 2017 11:56:08 GMT</pubDate>
    <dc:creator>harsmarvania57</dc:creator>
    <dc:date>2017-12-04T11:56:08Z</dc:date>
    <item>
      <title>Extracting the date from a filename without modifying the datetime.xml</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/Extracting-the-date-from-a-filename-without-modifying-the/m-p/326002#M5678</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I'm trying to extract the date from a filename without having to configure the config.file, i want to be able to achieve this through the search panel.&lt;/P&gt;

&lt;P&gt;This is my file name: name_name_20171130.txt&lt;/P&gt;

&lt;P&gt;This is the regular expression I've found that is the closest to helping me achieve what I need:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="name_name_20171130.txt" host="xxx" |   rex field= source="(?&amp;lt;date&amp;gt;[\d/]+)\s\w+" |table _raw 
ITEM, SOH_DIFF, field
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Alternatively, this expression: (?\d{8})&lt;/P&gt;

&lt;P&gt;Please Help!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:07:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/Extracting-the-date-from-a-filename-without-modifying-the/m-p/326002#M5678</guid>
      <dc:creator>mahbs</dc:creator>
      <dc:date>2020-09-29T17:07:48Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting the date from a filename without modifying the datetime.xml</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/Extracting-the-date-from-a-filename-without-modifying-the/m-p/326003#M5679</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;Can you please try this query, it will extract date from your source file name in &lt;CODE&gt;date&lt;/CODE&gt; field.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="name_name_20171130.txt" host="xxx" |   rex field=source "(?:[^\_]*\_){2}(?&amp;lt;date&amp;gt;.*)\.txt" |table _raw, ITEM, SOH_DIFF, date
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I hope this helps.&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Harshil&lt;/P&gt;</description>
      <pubDate>Mon, 04 Dec 2017 11:56:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/Extracting-the-date-from-a-filename-without-modifying-the/m-p/326003#M5679</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2017-12-04T11:56:08Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting the date from a filename without modifying the datetime.xml</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/Extracting-the-date-from-a-filename-without-modifying-the/m-p/326004#M5680</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 04 Dec 2017 12:02:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/Extracting-the-date-from-a-filename-without-modifying-the/m-p/326004#M5680</guid>
      <dc:creator>mahbs</dc:creator>
      <dc:date>2017-12-04T12:02:14Z</dc:date>
    </item>
  </channel>
</rss>

