<?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: Some RegEx help with date formatting in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Some-RegEx-help-with-date-formatting/m-p/20622#M3261</link>
    <description>&lt;P&gt;The REGEX would be the same, i.e. &lt;/P&gt;

&lt;P&gt;[^\s]+&lt;/P&gt;

&lt;P&gt;if your event text contains square brackets, you need to escape them, otherwise they will be treated as part of the regex, i.e. \[CDATA\[&lt;/P&gt;

&lt;P&gt;Please mark the question as answered if this solved your problem. Thanks.&lt;/P&gt;

&lt;P&gt;Kristian&lt;/P&gt;</description>
    <pubDate>Tue, 10 Apr 2012 07:06:49 GMT</pubDate>
    <dc:creator>kristian_kolb</dc:creator>
    <dc:date>2012-04-10T07:06:49Z</dc:date>
    <item>
      <title>Some RegEx help with date formatting</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Some-RegEx-help-with-date-formatting/m-p/20618#M3257</link>
      <description>&lt;P&gt;I am extracting a date/time stamp out of some XML; however, I need to strip out the time from the string.&lt;/P&gt;

&lt;P&gt;i.e. - 3/7/2012 2:25:52 PM (GMT) --&amp;gt; needs to be: 3/7/2012&lt;/P&gt;

&lt;P&gt;What would the REGEX be and would that regex be in the props.conf or can it go in the search string?&lt;/P&gt;

&lt;P&gt;Here is the entry in props = EXTRACT-CreateTimeStamp_GMT = (?i)&lt;CREATETIMESTAMPGMT&gt;(?P&lt;CREATETIMESTAMP_GMT&gt;[^&amp;lt;]+)&lt;/CREATETIMESTAMP_GMT&gt;&lt;/CREATETIMESTAMPGMT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 11:38:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Some-RegEx-help-with-date-formatting/m-p/20618#M3257</guid>
      <dc:creator>efelder0</dc:creator>
      <dc:date>2020-09-28T11:38:10Z</dc:date>
    </item>
    <item>
      <title>Re: Some RegEx help with date formatting</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Some-RegEx-help-with-date-formatting/m-p/20619#M3258</link>
      <description>&lt;P&gt;not really sure what you are wanting&lt;BR /&gt;
[\d]{1,2}/[\d]{1,2}/[\d]{4} will grab 3/7/2012 or 12/12/2012 , etc.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Apr 2012 02:41:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Some-RegEx-help-with-date-formatting/m-p/20619#M3258</guid>
      <dc:creator>cvajs</dc:creator>
      <dc:date>2012-04-06T02:41:01Z</dc:date>
    </item>
    <item>
      <title>Re: Some RegEx help with date formatting</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Some-RegEx-help-with-date-formatting/m-p/20620#M3259</link>
      <description>&lt;P&gt;If your XML looks something like this;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;blaha&amp;gt;BLAHA&amp;lt;/blaha&amp;gt;
&amp;lt;createtimestampgmt&amp;gt;3/7/2012 2:25:52 PM (GMT)&amp;lt;/createtimestampgmt&amp;gt;
&amp;lt;blaha2&amp;gt;BLAHA2&amp;lt;/blaha2&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;the following props.conf extract would get you the date only&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;EXTRACT-DateFromTimeStamp = (?i)&amp;lt;createtimestampgmt&amp;gt;(?P&amp;lt;createtimestamp_gmt&amp;gt;[^\s]+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;i.e. read everything from the end of the start tag up to the first whitespace character, and save it as  (the somewhat odd name) &lt;CODE&gt;createtimestamp_gmt&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Hope this helps,&lt;/P&gt;

&lt;P&gt;Kristian&lt;/P&gt;</description>
      <pubDate>Fri, 06 Apr 2012 13:10:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Some-RegEx-help-with-date-formatting/m-p/20620#M3259</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2012-04-06T13:10:51Z</dc:date>
    </item>
    <item>
      <title>Re: Some RegEx help with date formatting</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Some-RegEx-help-with-date-formatting/m-p/20621#M3260</link>
      <description>&lt;P&gt;Yes, that worked. However, I have another field that requires reformatting. But, this time I am doing my field extraction from the transforms.conf. For example, I am pulling a field called "IncidentTime" and its value is 12/11/2011 11:16:48 PM. Here is the entry in transforms.conf: &lt;BR /&gt;
REGEX = (?i)&lt;INCIDENTTIME&gt;&amp;lt;![CDATA[(?P&lt;INCIDENTTIME&gt;[a-zA-Z -:\d]+)(?=])&lt;/INCIDENTTIME&gt;&lt;/INCIDENTTIME&gt;&lt;/P&gt;

&lt;P&gt;What would the new REGEX be to only include the date string? or would it be better to use the strptime function from within the search?&lt;/P&gt;</description>
      <pubDate>Mon, 09 Apr 2012 15:15:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Some-RegEx-help-with-date-formatting/m-p/20621#M3260</guid>
      <dc:creator>efelder0</dc:creator>
      <dc:date>2012-04-09T15:15:35Z</dc:date>
    </item>
    <item>
      <title>Re: Some RegEx help with date formatting</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Some-RegEx-help-with-date-formatting/m-p/20622#M3261</link>
      <description>&lt;P&gt;The REGEX would be the same, i.e. &lt;/P&gt;

&lt;P&gt;[^\s]+&lt;/P&gt;

&lt;P&gt;if your event text contains square brackets, you need to escape them, otherwise they will be treated as part of the regex, i.e. \[CDATA\[&lt;/P&gt;

&lt;P&gt;Please mark the question as answered if this solved your problem. Thanks.&lt;/P&gt;

&lt;P&gt;Kristian&lt;/P&gt;</description>
      <pubDate>Tue, 10 Apr 2012 07:06:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Some-RegEx-help-with-date-formatting/m-p/20622#M3261</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2012-04-10T07:06:49Z</dc:date>
    </item>
    <item>
      <title>Re: Some RegEx help with date formatting</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Some-RegEx-help-with-date-formatting/m-p/20623#M3262</link>
      <description>&lt;P&gt;efelder0,&lt;BR /&gt;
what do you mean by "date". date as in "MM/DD/YYYY" or date as "MM/DD/YYYY HH:MM:SS (AM|PM)"&lt;/P&gt;

&lt;P&gt;i would opt to use [\d]{2}/[\d]{2}/[\d]{4} to grab MM/DD/YYYY just in case the space comes up missing (not likely, but you never know)&lt;/P&gt;</description>
      <pubDate>Tue, 10 Apr 2012 12:55:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Some-RegEx-help-with-date-formatting/m-p/20623#M3262</guid>
      <dc:creator>cvajs</dc:creator>
      <dc:date>2012-04-10T12:55:14Z</dc:date>
    </item>
  </channel>
</rss>

