<?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 edit my regular expression to extract the date and time from my sample data? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-regular-expression-to-extract-the-date-and-time/m-p/273550#M82488</link>
    <description>&lt;P&gt;For Date &amp;amp; Time, this should work. Also I would not recommend creating one big regex, even if one character position changes, your fields will not be exractracted and will become very difficult to debug. I would recommend treating this as a space delimited in field extraction UI (IFX). Regardless, for date/time, you need to escape the &lt;CODE&gt;[&lt;/CODE&gt; &amp;amp; &lt;CODE&gt;]&lt;/CODE&gt; chars. Like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\[(?&amp;lt;datetime&amp;gt;[^\s]+)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 09 Sep 2016 22:10:39 GMT</pubDate>
    <dc:creator>sundareshr</dc:creator>
    <dc:date>2016-09-09T22:10:39Z</dc:date>
    <item>
      <title>How to edit my regular expression to extract the date and time from my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-regular-expression-to-extract-the-date-and-time/m-p/273549#M82487</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have data that looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"-" 10.30.28.1 "10.30.28.1" - - [09/Sep/2016:16:58:31 -0500] "GET /ICHealthCheck/serverstatus HTTP/1.0" 200 2 0 UCT-11666 "-" "-" "-"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And I'm trying to write a regular expression that extracts several fields:&lt;/P&gt;

&lt;P&gt;So far I have:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?P&amp;lt;host&amp;gt;[^"]+)[^ \n]* (?P&amp;lt;remote_host&amp;gt;[^ ]+)\s+(?P&amp;lt;x_forwarded_for&amp;gt;[^ ]+)\s+(?P&amp;lt;remote_logname&amp;gt;[^ ]+)\s+(?P&amp;lt;remote_user&amp;gt;\-)\s+
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And this works, but I'm stuck at extracting the date and time &lt;CODE&gt;09/Sep/2016:16:58:31&lt;/CODE&gt; in this case. The &lt;CODE&gt;[&lt;/CODE&gt; is throwing me off.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Sep 2016 22:02:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-regular-expression-to-extract-the-date-and-time/m-p/273549#M82487</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2016-09-09T22:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my regular expression to extract the date and time from my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-regular-expression-to-extract-the-date-and-time/m-p/273550#M82488</link>
      <description>&lt;P&gt;For Date &amp;amp; Time, this should work. Also I would not recommend creating one big regex, even if one character position changes, your fields will not be exractracted and will become very difficult to debug. I would recommend treating this as a space delimited in field extraction UI (IFX). Regardless, for date/time, you need to escape the &lt;CODE&gt;[&lt;/CODE&gt; &amp;amp; &lt;CODE&gt;]&lt;/CODE&gt; chars. Like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\[(?&amp;lt;datetime&amp;gt;[^\s]+)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Sep 2016 22:10:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-regular-expression-to-extract-the-date-and-time/m-p/273550#M82488</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-09-09T22:10:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my regular expression to extract the date and time from my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-regular-expression-to-extract-the-date-and-time/m-p/273551#M82489</link>
      <description>&lt;P&gt;Thanks Sundareshr!  Maybe a space delimited extraction is the way to go.  Let me try that instead.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Sep 2016 22:15:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-regular-expression-to-extract-the-date-and-time/m-p/273551#M82489</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2016-09-09T22:15:41Z</dc:date>
    </item>
  </channel>
</rss>

