<?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 difficulty with host / path discrimination in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/regex-difficulty-with-host-path-discrimination/m-p/148814#M41605</link>
    <description>&lt;P&gt;Tried this and worked fine.&lt;/P&gt;

&lt;P&gt;|stats count |fields - count | eval host="host.in.com/inbox/to/file,host.incinbox/to/another-file,host.inbox.com/inbox/to/file,host.inboxcinbox/to/another-file" | eval host=split(host,",") | mvexpand host | rex field=host "^(?&lt;HOSTNAME&gt;[^/]*)(/)*inbox"&lt;/HOSTNAME&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 16:30:53 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2020-09-28T16:30:53Z</dc:date>
    <item>
      <title>regex difficulty with host / path discrimination</title>
      <link>https://community.splunk.com/t5/Splunk-Search/regex-difficulty-with-host-path-discrimination/m-p/148811#M41602</link>
      <description>&lt;P&gt;I have a log file that has the host as either an IP address OR a FQDN.  This is easy, right.  Nope.  The format can be:&lt;/P&gt;

&lt;P&gt;192.168.1.1/inbox/to/file&lt;BR /&gt;&lt;BR /&gt;
or&lt;BR /&gt;&lt;BR /&gt;
192 .168.1.1inbox/to/another-file&lt;BR /&gt;&lt;BR /&gt;
or&lt;BR /&gt;&lt;BR /&gt;
host.com/inbox/to/file&lt;BR /&gt;&lt;BR /&gt;
or&lt;BR /&gt;&lt;BR /&gt;
host.cominbox/to/another-file&lt;/P&gt;

&lt;P&gt;I can regex the ip easy enough \d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}&lt;/P&gt;

&lt;P&gt;so that handles the first two . .  &lt;/P&gt;

&lt;P&gt;For the third one, I can do a greedy up to / [^/]+&lt;/P&gt;

&lt;P&gt;problem is the last one, actually... &lt;/P&gt;

&lt;P&gt;The perfect solution would be one regex for the extract regardless.  Written out it would be:&lt;/P&gt;

&lt;P&gt;everything up to either / or the word 'inbox' &lt;/P&gt;

&lt;P&gt;That way, I can do the extract as :&lt;/P&gt;

&lt;P&gt;(?&amp;lt;HOST&amp;gt;(provided regex))&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;

&lt;P&gt;The full entry is gathered by:&lt;/P&gt;

&lt;P&gt;^\d{4}.\d{2}.\d{2}\s\d{2}:\d{2}\s(?&amp;lt;Transmissionformat&amp;gt;\w)\s(&amp;lt;Fileone&amp;gt;[^-]+)\s(?&amp;lt;DIRECTION&amp;gt;\S{3})\s(?&amp;lt;HOST&amp;gt;???????)(?&amp;lt;Filetwo&amp;gt;[^$]+)$&lt;/P&gt;

&lt;P&gt;I need the ???? part replaced with a regex that will do as described above.  &lt;/P&gt;

&lt;P&gt;2014.04.28 14:10  B n:\path\one\to\fileone &amp;lt;-- 172.21.1.2Inbox/path/filetwo&lt;/P&gt;</description>
      <pubDate>Thu, 01 May 2014 15:10:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/regex-difficulty-with-host-path-discrimination/m-p/148811#M41602</guid>
      <dc:creator>tyronetv</dc:creator>
      <dc:date>2014-05-01T15:10:30Z</dc:date>
    </item>
    <item>
      <title>Re: regex difficulty with host / path discrimination</title>
      <link>https://community.splunk.com/t5/Splunk-Search/regex-difficulty-with-host-path-discrimination/m-p/148812#M41603</link>
      <description>&lt;P&gt;This works with your sample data.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|stats count |fields - count | eval host="192.168.1.1/inbox/to/file,192 .168.1.1inbox/to/another-file,host.com/inbox/to/file,host.cominbox/to/another-file" | eval host=split(host,",") | mvexpand host | rex field=host "^(?&amp;lt;hostName&amp;gt;[^/]*)(/)*inbox"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 May 2014 16:11:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/regex-difficulty-with-host-path-discrimination/m-p/148812#M41603</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-05-01T16:11:29Z</dc:date>
    </item>
    <item>
      <title>Re: regex difficulty with host / path discrimination</title>
      <link>https://community.splunk.com/t5/Splunk-Search/regex-difficulty-with-host-path-discrimination/m-p/148813#M41604</link>
      <description>&lt;P&gt;(?&amp;lt;HOST&amp;gt;[^/(?&amp;lt;!Ii)]+)&lt;/P&gt;

&lt;P&gt;That sort of works.. but concerned if the FQDN has an 'i' in it.&lt;/P&gt;</description>
      <pubDate>Thu, 01 May 2014 17:35:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/regex-difficulty-with-host-path-discrimination/m-p/148813#M41604</guid>
      <dc:creator>tyronetv</dc:creator>
      <dc:date>2014-05-01T17:35:05Z</dc:date>
    </item>
    <item>
      <title>Re: regex difficulty with host / path discrimination</title>
      <link>https://community.splunk.com/t5/Splunk-Search/regex-difficulty-with-host-path-discrimination/m-p/148814#M41605</link>
      <description>&lt;P&gt;Tried this and worked fine.&lt;/P&gt;

&lt;P&gt;|stats count |fields - count | eval host="host.in.com/inbox/to/file,host.incinbox/to/another-file,host.inbox.com/inbox/to/file,host.inboxcinbox/to/another-file" | eval host=split(host,",") | mvexpand host | rex field=host "^(?&lt;HOSTNAME&gt;[^/]*)(/)*inbox"&lt;/HOSTNAME&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:30:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/regex-difficulty-with-host-path-discrimination/m-p/148814#M41605</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2020-09-28T16:30:53Z</dc:date>
    </item>
  </channel>
</rss>

