<?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: Field extraction problems in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Field-extraction-problems/m-p/22097#M3743</link>
    <description>&lt;P&gt;Hexx,&lt;BR /&gt;
Thanks for your reply. Doesn't look like this is quite what I want for an extraction. Thats my fault, I changed the info in the OP to reflect the values that will be present in the field (sorry!).&lt;/P&gt;

&lt;P&gt;What is interesting, everything points to both my regex and the splunk generated regex working correctly. In-fact they do on fields with no port information. When there is port information present, the regex works during search time and during tests (in python and rubular).&lt;/P&gt;</description>
    <pubDate>Tue, 31 Jul 2012 17:02:36 GMT</pubDate>
    <dc:creator>Brandon_ganem1</dc:creator>
    <dc:date>2012-07-31T17:02:36Z</dc:date>
    <item>
      <title>Field extraction problems</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-extraction-problems/m-p/22095#M3741</link>
      <description>&lt;P&gt;I'm having an issue with extracting a field from proxy log information. I've created a regex that should be extracting the TLD of the domain visited (com net and etc).&lt;/P&gt;

&lt;P&gt;I've tried two regex patterns.&lt;BR /&gt;
REGEX = ^(?i).&lt;EM&gt;.(?&lt;TLD&gt;[a-zA-Z]+)(:\d+)?$     SPLUNK GENERATIED&lt;BR /&gt;
REGEX = (?i)..&lt;/TLD&gt;&lt;/EM&gt;?.(?P&lt;TLD&gt;[a-z]+)(?=/)          My own regex&lt;/TLD&gt;&lt;/P&gt;

&lt;P&gt;Sample information (note the field will include only google.com or goole.com:port num):&lt;/P&gt;

&lt;P&gt;WORKS ON:&lt;BR /&gt;
google.com&lt;BR /&gt;
google.com/something/goes/here.html&lt;/P&gt;

&lt;P&gt;DOESN"T WORK:&lt;BR /&gt;
google.com:443&lt;BR /&gt;
google.com:443/something/goes/here.html&lt;BR /&gt;
testsite.com:8080&lt;BR /&gt;
testsite.com:8080/something/goes/here.html&lt;/P&gt;

&lt;P&gt;Transforms entry: &lt;BR /&gt;
[tld_extract]&lt;BR /&gt;
SOURCE_KEY = domain0&lt;BR /&gt;
REGEX = (?i)..*?.(?P&lt;TLD&gt;[a-z]+)(?=/)&lt;/TLD&gt;&lt;/P&gt;

&lt;P&gt;Also, both regexes work if you use them search time regardless of the website.&lt;/P&gt;

&lt;P&gt;EXAMPLE:&lt;BR /&gt;
index=myproxyindex sourcetype="mysourcetype" | rex field=domain "(?i)..*?.(?P&lt;TLD&gt;[a-z]+)(?=/)"&lt;/TLD&gt;&lt;/P&gt;

&lt;P&gt;Works on both traffic with ports in the "domain" field and without.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:10:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-extraction-problems/m-p/22095#M3741</guid>
      <dc:creator>Brandon_ganem1</dc:creator>
      <dc:date>2020-09-28T12:10:34Z</dc:date>
    </item>
    <item>
      <title>Re: Field extraction problems</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-extraction-problems/m-p/22096#M3742</link>
      <description>&lt;P&gt;How about:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;REGEX = \.\w+(\.\w+)(?:$|/|:\d+)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 31 Jul 2012 15:25:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-extraction-problems/m-p/22096#M3742</guid>
      <dc:creator>hexx</dc:creator>
      <dc:date>2012-07-31T15:25:03Z</dc:date>
    </item>
    <item>
      <title>Re: Field extraction problems</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-extraction-problems/m-p/22097#M3743</link>
      <description>&lt;P&gt;Hexx,&lt;BR /&gt;
Thanks for your reply. Doesn't look like this is quite what I want for an extraction. Thats my fault, I changed the info in the OP to reflect the values that will be present in the field (sorry!).&lt;/P&gt;

&lt;P&gt;What is interesting, everything points to both my regex and the splunk generated regex working correctly. In-fact they do on fields with no port information. When there is port information present, the regex works during search time and during tests (in python and rubular).&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jul 2012 17:02:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-extraction-problems/m-p/22097#M3743</guid>
      <dc:creator>Brandon_ganem1</dc:creator>
      <dc:date>2012-07-31T17:02:36Z</dc:date>
    </item>
    <item>
      <title>Re: Field extraction problems</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-extraction-problems/m-p/22098#M3744</link>
      <description>&lt;P&gt;So, to be clear, you want the regex to extract "google.com" out of "google.com:443/something/goes/here.html" for example?&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jul 2012 17:15:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-extraction-problems/m-p/22098#M3744</guid>
      <dc:creator>hexx</dc:creator>
      <dc:date>2012-07-31T17:15:06Z</dc:date>
    </item>
    <item>
      <title>Re: Field extraction problems</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-extraction-problems/m-p/22099#M3745</link>
      <description>&lt;P&gt;So I played with your regex and got it to work for what I was looking for. Updated regex: \w+(.(?&lt;TLD&gt;[a-zA-Z]+))(?:$|\/|:\d+)&lt;/TLD&gt;&lt;/P&gt;

&lt;P&gt;Thank you for your help. I'm thinking splunk didn't like the use of &lt;CODE&gt;?&lt;/CODE&gt; to make (:\d+) optional in ^(?i).*.(?&lt;TLD&gt;[a-zA-Z]+)(:\d+)?$&lt;/TLD&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jul 2012 20:16:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-extraction-problems/m-p/22099#M3745</guid>
      <dc:creator>Brandon_ganem1</dc:creator>
      <dc:date>2012-07-31T20:16:24Z</dc:date>
    </item>
  </channel>
</rss>

