<?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 Extracting selected hosts with regex / Regex hosts with exceptions in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Extracting-selected-hosts-with-regex-Regex-hosts-with-exceptions/m-p/42279#M9866</link>
    <description>&lt;P&gt;Hi Splunkers,&lt;/P&gt;

&lt;P&gt;I am trying to extract the hosts via regex.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host="*" | regex host="([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}" | dedup host | table host | sort -host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The problem is that some hosts have a name and some of them come with the  full domain name.&lt;/P&gt;

&lt;P&gt;For example:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE&gt;host&lt;BR /&gt;
xd-test-app05.abc-xz.com&lt;BR /&gt;
xd-test-app04.abc-xz.com&lt;BR /&gt;
xd-test-app03&lt;BR /&gt;
xd-test-app03.abc-xz.com&lt;BR /&gt;
xd-test-app02&lt;BR /&gt;
xd-test-app02.abc-xz.com&lt;BR /&gt;
xd-test-app01.abc-xz.com&lt;BR /&gt;
xd-shared-db01.abc-xz.com&lt;BR /&gt;
xd-qa-app08.abc-xz.com&lt;BR /&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;/P&gt;

&lt;P&gt;Is there a way to add an exception to my regex?&lt;/P&gt;

&lt;P&gt;Thanks in advance for your help.&lt;/P&gt;

&lt;P&gt;regards&lt;BR /&gt;
Mike&lt;/P&gt;</description>
    <pubDate>Mon, 25 Feb 2013 15:57:43 GMT</pubDate>
    <dc:creator>lemikg</dc:creator>
    <dc:date>2013-02-25T15:57:43Z</dc:date>
    <item>
      <title>Extracting selected hosts with regex / Regex hosts with exceptions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-selected-hosts-with-regex-Regex-hosts-with-exceptions/m-p/42279#M9866</link>
      <description>&lt;P&gt;Hi Splunkers,&lt;/P&gt;

&lt;P&gt;I am trying to extract the hosts via regex.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host="*" | regex host="([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}" | dedup host | table host | sort -host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The problem is that some hosts have a name and some of them come with the  full domain name.&lt;/P&gt;

&lt;P&gt;For example:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE&gt;host&lt;BR /&gt;
xd-test-app05.abc-xz.com&lt;BR /&gt;
xd-test-app04.abc-xz.com&lt;BR /&gt;
xd-test-app03&lt;BR /&gt;
xd-test-app03.abc-xz.com&lt;BR /&gt;
xd-test-app02&lt;BR /&gt;
xd-test-app02.abc-xz.com&lt;BR /&gt;
xd-test-app01.abc-xz.com&lt;BR /&gt;
xd-shared-db01.abc-xz.com&lt;BR /&gt;
xd-qa-app08.abc-xz.com&lt;BR /&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;/P&gt;

&lt;P&gt;Is there a way to add an exception to my regex?&lt;/P&gt;

&lt;P&gt;Thanks in advance for your help.&lt;/P&gt;

&lt;P&gt;regards&lt;BR /&gt;
Mike&lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2013 15:57:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-selected-hosts-with-regex-Regex-hosts-with-exceptions/m-p/42279#M9866</guid>
      <dc:creator>lemikg</dc:creator>
      <dc:date>2013-02-25T15:57:43Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting selected hosts with regex / Regex hosts with exceptions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-selected-hosts-with-regex-Regex-hosts-with-exceptions/m-p/42280#M9867</link>
      <description>&lt;P&gt;What does the source data look like, are they all fqdn's?  Why do you have . in your capture group, as that should match any character.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2013 17:26:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-selected-hosts-with-regex-Regex-hosts-with-exceptions/m-p/42280#M9867</guid>
      <dc:creator>mikelanghorst</dc:creator>
      <dc:date>2013-02-25T17:26:19Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting selected hosts with regex / Regex hosts with exceptions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-selected-hosts-with-regex-Regex-hosts-with-exceptions/m-p/42281#M9868</link>
      <description>&lt;P&gt;Hi, I can't answer the question regarding The "." in my capture group since I just copied that from an example. St this point I can't provide Any sourcedata since i am not in The office any more. But The source is nothing special Art all.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2013 17:38:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-selected-hosts-with-regex-Regex-hosts-with-exceptions/m-p/42281#M9868</guid>
      <dc:creator>lemikg</dc:creator>
      <dc:date>2013-02-25T17:38:42Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting selected hosts with regex / Regex hosts with exceptions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-selected-hosts-with-regex-Regex-hosts-with-exceptions/m-p/42282#M9869</link>
      <description>&lt;P&gt;A lot of the expression was lost in the formatting, now (amongst other things) the period is escaped properly.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2013 17:49:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-selected-hosts-with-regex-Regex-hosts-with-exceptions/m-p/42282#M9869</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2013-02-25T17:49:44Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting selected hosts with regex / Regex hosts with exceptions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-selected-hosts-with-regex-Regex-hosts-with-exceptions/m-p/42283#M9870</link>
      <description>&lt;P&gt;If they're all from the same domain&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host="*" | rex field=host "^(?&amp;lt;host&amp;gt;[^.]+)" | dedup host | table host | sort -host
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Feb 2013 22:33:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-selected-hosts-with-regex-Regex-hosts-with-exceptions/m-p/42283#M9870</guid>
      <dc:creator>jonuwz</dc:creator>
      <dc:date>2013-02-25T22:33:57Z</dc:date>
    </item>
  </channel>
</rss>

