<?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 that covers both cases in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regex-that-covers-both-cases/m-p/268146#M80667</link>
    <description>&lt;P&gt;This works with your sample data on regex101.com.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex "(?&amp;lt;IP&amp;gt;[^ ]+) (:\"(?&amp;lt;PartnerId&amp;gt;\w+)\" )?\"(?&amp;lt;correlationId&amp;gt;[^\"]+)\"\ \"(?&amp;lt;ServiceCall&amp;gt;.*?)\" (?&amp;lt;HTTP_Code&amp;gt;[\d]+) (?&amp;lt;HTTP_PayLoad&amp;gt;[\d]+) (?&amp;lt;Duration&amp;gt;.*)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 21 Jul 2016 11:59:40 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2016-07-21T11:59:40Z</dc:date>
    <item>
      <title>Regex that covers both cases</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-that-covers-both-cases/m-p/268144#M80665</link>
      <description>&lt;P&gt;I have the following log events both on the same source log:&lt;/P&gt;

&lt;P&gt;Log 1:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[21/Jul/2016:11:34:28 +0000] 99.125.125.201 "AB" "53096a9f-cef9-4047-83a5-07deda1d2939" "POST /call/service HTTP/1.1" 200 211 0.001
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Regex:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex "(?&amp;lt;IP&amp;gt;[^ ]+) \"(?&amp;lt;PartnerId&amp;gt;\\w+)\" \"(?&amp;lt;correlationId&amp;gt;[^\"]+)\"\ \"(?&amp;lt;ServiceCall&amp;gt;.*?)\" (?&amp;lt;HTTP_Code&amp;gt;[\d]+) (?&amp;lt;HTTP_PayLoad&amp;gt;[\d]+) (?&amp;lt;Duration&amp;gt;.*)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Log 2:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[21/Jul/2016:11:35:43 +0000] 99.125.95.251 "03483b34-1cc2-42d7-b612-db545efab897" "POST /call/service HTTP/1.1" 200 10448 0.002
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Regex:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex "(?&amp;lt;IP&amp;gt;[^ ]+) \"(?&amp;lt;correlationId&amp;gt;[^\"]+)\"\ \"(?&amp;lt;ServiceCall&amp;gt;.*?)\" (?&amp;lt;HTTP_Code&amp;gt;[\d]+) (?&amp;lt;HTTP_PayLoad&amp;gt;[\d]+) (?&amp;lt;Duration&amp;gt;.*)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Question:&lt;BR /&gt;
What will be the Regex that covers both cases?&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Lp&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2016 11:44:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-that-covers-both-cases/m-p/268144#M80665</guid>
      <dc:creator>lpolo</dc:creator>
      <dc:date>2016-07-21T11:44:56Z</dc:date>
    </item>
    <item>
      <title>Re: Regex that covers both cases</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-that-covers-both-cases/m-p/268145#M80666</link>
      <description>&lt;P&gt;What about this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "^\[\d{2}\/\w{3}\/\d{4}:\d{2}:\d{2}:\d{2} [\-\+]\d{4}\] (?&amp;lt;IP&amp;gt;[^ ]+) (\"(?&amp;lt;PartnerId&amp;gt;\w+)\" )?\"(?&amp;lt;correlationId&amp;gt;[^\"]+)\" \"(?&amp;lt;ServiceCall&amp;gt;[^\"]+)\" (?&amp;lt;HTTP_Code&amp;gt;[\d]+) (?&amp;lt;HTTP_PayLoad&amp;gt;[\d]+) (?&amp;lt;Duration&amp;gt;[\d\.]+)$"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Jul 2016 11:59:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-that-covers-both-cases/m-p/268145#M80666</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-07-21T11:59:09Z</dc:date>
    </item>
    <item>
      <title>Re: Regex that covers both cases</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-that-covers-both-cases/m-p/268146#M80667</link>
      <description>&lt;P&gt;This works with your sample data on regex101.com.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex "(?&amp;lt;IP&amp;gt;[^ ]+) (:\"(?&amp;lt;PartnerId&amp;gt;\w+)\" )?\"(?&amp;lt;correlationId&amp;gt;[^\"]+)\"\ \"(?&amp;lt;ServiceCall&amp;gt;.*?)\" (?&amp;lt;HTTP_Code&amp;gt;[\d]+) (?&amp;lt;HTTP_PayLoad&amp;gt;[\d]+) (?&amp;lt;Duration&amp;gt;.*)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Jul 2016 11:59:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-that-covers-both-cases/m-p/268146#M80667</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-07-21T11:59:40Z</dc:date>
    </item>
    <item>
      <title>Re: Regex that covers both cases</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-that-covers-both-cases/m-p/268147#M80668</link>
      <description>&lt;P&gt;It does not work. Thanks,&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2016 12:11:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-that-covers-both-cases/m-p/268147#M80668</guid>
      <dc:creator>lpolo</dc:creator>
      <dc:date>2016-07-21T12:11:57Z</dc:date>
    </item>
    <item>
      <title>Re: Regex that covers both cases</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-that-covers-both-cases/m-p/268148#M80669</link>
      <description>&lt;P&gt;It works in regex101.com.  Be sure to escape the '"' characters in your rex command.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2016 12:17:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-that-covers-both-cases/m-p/268148#M80669</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-07-21T12:17:05Z</dc:date>
    </item>
    <item>
      <title>Re: Regex that covers both cases</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-that-covers-both-cases/m-p/268149#M80670</link>
      <description>&lt;P&gt;It does work. &lt;BR /&gt;
Thanks,&lt;BR /&gt;
Lp&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2016 12:25:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-that-covers-both-cases/m-p/268149#M80670</guid>
      <dc:creator>lpolo</dc:creator>
      <dc:date>2016-07-21T12:25:44Z</dc:date>
    </item>
    <item>
      <title>Re: Regex that covers both cases</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-that-covers-both-cases/m-p/268150#M80671</link>
      <description>&lt;P&gt;No worries. If you are happy with the answer can you mark it as such so that others can benefit from it?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2016 13:00:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-that-covers-both-cases/m-p/268150#M80671</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-07-21T13:00:59Z</dc:date>
    </item>
  </channel>
</rss>

