<?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: is $ supported in regex for field extraction ? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202974#M58939</link>
    <description>&lt;P&gt;I think that's the solution. Judging by the example lauMarot gave, the IP is followed by a double quote before the actual end of line.&lt;/P&gt;</description>
    <pubDate>Tue, 02 Aug 2016 14:18:39 GMT</pubDate>
    <dc:creator>gabriel_vasseur</dc:creator>
    <dc:date>2016-08-02T14:18:39Z</dc:date>
    <item>
      <title>is $ supported in regex for field extraction ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202970#M58935</link>
      <description>&lt;P&gt;I've got the following log line and I wish I could extract the last IP address field:&lt;/P&gt;

&lt;P&gt;.................(variable number of fields)....."N/A","N/A","xxx.xxx.xxx.xxx"&lt;/P&gt;

&lt;P&gt;I used to think that something like the following should have worked&lt;/P&gt;

&lt;P&gt;(?P‹lastIP›\d+.\d+.\d+.\d+$)&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2016 14:02:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202970#M58935</guid>
      <dc:creator>lauMarot</dc:creator>
      <dc:date>2016-08-02T14:02:50Z</dc:date>
    </item>
    <item>
      <title>Re: is $ supported in regex for field extraction ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202971#M58936</link>
      <description>&lt;P&gt;The &lt;CODE&gt;$&lt;/CODE&gt; represent the end of a line in multi-lin, so it should work if that IP is the end of the line.. &lt;/P&gt;

&lt;P&gt;But why use a dollar sign? &lt;/P&gt;

&lt;P&gt;Try this &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;(?P&amp;lt;IP_Name&amp;gt;\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;This will say look for a digit who's length is from 1-3 digits followed by a &lt;CODE&gt;.&lt;/CODE&gt; follow by 1-3 digits, then a &lt;CODE&gt;.&lt;/CODE&gt;, then 1-3 digits, then a &lt;CODE&gt;.&lt;/CODE&gt; follow by 1-3 digits &lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2016 14:13:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202971#M58936</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2016-08-02T14:13:14Z</dc:date>
    </item>
    <item>
      <title>Re: is $ supported in regex for field extraction ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202972#M58937</link>
      <description>&lt;P&gt;Try moving the $ outside of the parenthesis.  &lt;/P&gt;

&lt;P&gt;,"(?P‹lastIP›\d+.\d+.\d+.\d+)"$&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2016 14:14:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202972#M58937</guid>
      <dc:creator>sjohnson_splunk</dc:creator>
      <dc:date>2016-08-02T14:14:51Z</dc:date>
    </item>
    <item>
      <title>Re: is $ supported in regex for field extraction ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202973#M58938</link>
      <description>&lt;P&gt;You forgot the &lt;CODE&gt;1,&lt;/CODE&gt; for the last two &lt;CODE&gt;\d&lt;/CODE&gt; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
I think the anchor might be needed if there are other IP addresses in the same event.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2016 14:17:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202973#M58938</guid>
      <dc:creator>gabriel_vasseur</dc:creator>
      <dc:date>2016-08-02T14:17:19Z</dc:date>
    </item>
    <item>
      <title>Re: is $ supported in regex for field extraction ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202974#M58939</link>
      <description>&lt;P&gt;I think that's the solution. Judging by the example lauMarot gave, the IP is followed by a double quote before the actual end of line.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2016 14:18:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202974#M58939</guid>
      <dc:creator>gabriel_vasseur</dc:creator>
      <dc:date>2016-08-02T14:18:39Z</dc:date>
    </item>
    <item>
      <title>Re: is $ supported in regex for field extraction ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202975#M58940</link>
      <description>&lt;P&gt;Whoops, thanks for pointing that out. Yes true, if he has multiple unique IP addresses then he could use a dollar sign or a lookbehind &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;(?P&amp;lt;LastIP&amp;gt;(?&amp;lt;=N\/A\"\,\")\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2016 14:24:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202975#M58940</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2016-08-02T14:24:34Z</dc:date>
    </item>
    <item>
      <title>Re: is $ supported in regex for field extraction ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202976#M58941</link>
      <description>&lt;P&gt;Yes, but you can't expect the previous field to always have the &lt;CODE&gt;N/A&lt;/CODE&gt;value, so I believe a &lt;CODE&gt;$&lt;/CODE&gt;would be more appropriate.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2016 14:30:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202976#M58941</guid>
      <dc:creator>gabriel_vasseur</dc:creator>
      <dc:date>2016-08-02T14:30:40Z</dc:date>
    </item>
    <item>
      <title>Re: is $ supported in regex for field extraction ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202977#M58942</link>
      <description>&lt;P&gt;(?P\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}) match the first IP adress found in my log line &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;BR /&gt;
adding $ (outside or inside parethesis) breaks any match&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2016 14:32:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202977#M58942</guid>
      <dc:creator>lauMarot</dc:creator>
      <dc:date>2016-08-02T14:32:36Z</dc:date>
    </item>
    <item>
      <title>Re: is $ supported in regex for field extraction ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202978#M58943</link>
      <description>&lt;P&gt;nice try ... but it does not work &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; &lt;BR /&gt;
Generally I use the wizzard and not type in dircetly my regex but taht time wizzard generate the following error : &lt;/P&gt;

&lt;P&gt;The extraction failed. If you are extracting multiple fields, try removing one or more fields. Start with extractions that are embedded within longer text strings. &lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2016 14:35:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202978#M58943</guid>
      <dc:creator>lauMarot</dc:creator>
      <dc:date>2016-08-02T14:35:31Z</dc:date>
    </item>
    <item>
      <title>Re: is $ supported in regex for field extraction ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202979#M58944</link>
      <description>&lt;P&gt;Can you provide us with a few more lines of sample data? Is there always an NA value in front of the IP or can it vary? &lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2016 14:38:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202979#M58944</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2016-08-02T14:38:32Z</dc:date>
    </item>
    <item>
      <title>Re: is $ supported in regex for field extraction ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202980#M58945</link>
      <description>&lt;P&gt;Forget the wizard and use rex directly:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;YOUR SEARCH HERE | rex field=_raw ",\"(?P‹lastIP›\d+\.\d+\.\d+\.\d+)\"$"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;lauMarot: that should match the example data you gave us. If it doesn't, please give more example of data.&lt;/P&gt;

&lt;P&gt;sjohnson: writing this, I realised you needed to escape the dots in there, otherwise technically your regex could match any long number...&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2016 14:40:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202980#M58945</guid>
      <dc:creator>gabriel_vasseur</dc:creator>
      <dc:date>2016-08-02T14:40:15Z</dc:date>
    </item>
    <item>
      <title>Re: is $ supported in regex for field extraction ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202981#M58946</link>
      <description>&lt;P&gt;Everyone is on the right track. And any and all of these solutions should have been successful. So what we'll need is a solid sample of two events that show the varied fields. Because there is something you are not noticing or telling us... and all these eyes here should be able to see if you let us. You can anonymize the data by changing a few key numbers. Do not turn it into garbage or we can't give a 1:1 test on the data without editing it ourselves.&lt;/P&gt;

&lt;P&gt;I used a sample from an httpd access_combined log on a public facing server. It has two IP addresses&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;158.111.236.56 - - [01/Aug/2016:11:03:07 -0700] "GET /atlas/NewDay/1/2/2/2/2/2/2/0/2.png?c=1470074467 HTTP/1.1" 200 222762 "http://splunkcraft.splunkoxygen.com/atlas/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36"51.0.274.106
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will capture the last IP only that is immediately followed by the end of the event in a single line event and in a multiline event the &lt;CODE&gt;$&lt;/CODE&gt; is present after each &lt;CODE&gt;\n&lt;/CODE&gt; carriage at the end of EACH line (which could possibly be your problem).  It works in my sample data.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?&amp;lt;IP&amp;gt;\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will capture the first IP only&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ^(?&amp;lt;IP&amp;gt;\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I have done in the past when unsure as to whether something was being considered single or multiline by Splunk (or rather by any regex engine) I prefix the regex with the specific flag, which tells regex how to treat the line ending very deliberately.  so &lt;BR /&gt;
&lt;CODE&gt;(?s)(?&amp;lt;IP&amp;gt;\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$&lt;/CODE&gt;&lt;BR /&gt;
might work...   I'm honestly not sure if it forces the look at the end of the event or if it's just properly labeling it. so no guarantees &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2016 16:09:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202981#M58946</guid>
      <dc:creator>rsennett_splunk</dc:creator>
      <dc:date>2016-08-02T16:09:46Z</dc:date>
    </item>
    <item>
      <title>Re: is $ supported in regex for field extraction ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202982#M58947</link>
      <description>&lt;P&gt;thx for helping but it does not work with attached log sample (to large for text input field)&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2016 08:12:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202982#M58947</guid>
      <dc:creator>lauMarot</dc:creator>
      <dc:date>2016-08-03T08:12:22Z</dc:date>
    </item>
    <item>
      <title>Re: is $ supported in regex for field extraction ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202983#M58948</link>
      <description>&lt;P&gt;&lt;A href="https://answers.splunk.comstorage/temp/153190-log-extracts-anon.zip"&gt;link text&lt;/A&gt;log sample &lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2016 08:13:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202983#M58948</guid>
      <dc:creator>lauMarot</dc:creator>
      <dc:date>2016-08-03T08:13:06Z</dc:date>
    </item>
    <item>
      <title>Re: is $ supported in regex for field extraction ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202984#M58949</link>
      <description>&lt;P&gt;I've attached a three events file sample&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2016 08:17:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202984#M58949</guid>
      <dc:creator>lauMarot</dc:creator>
      <dc:date>2016-08-03T08:17:22Z</dc:date>
    </item>
    <item>
      <title>Re: is $ supported in regex for field extraction ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202985#M58950</link>
      <description>&lt;P&gt;I've attached a three events file sample&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2016 09:38:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202985#M58950</guid>
      <dc:creator>lauMarot</dc:creator>
      <dc:date>2016-08-03T09:38:09Z</dc:date>
    </item>
    <item>
      <title>Re: is $ supported in regex for field extraction ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202986#M58951</link>
      <description>&lt;P&gt;Apparently there is some white space at the end of the lines. So this should take care of it:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?P‹lastIP›\d+\.\d+\.\d+\.\d+)"\s*$
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 Aug 2016 10:34:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202986#M58951</guid>
      <dc:creator>gabriel_vasseur</dc:creator>
      <dc:date>2016-08-03T10:34:28Z</dc:date>
    </item>
    <item>
      <title>Re: is $ supported in regex for field extraction ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202987#M58952</link>
      <description>&lt;P&gt;of course ... so sorry, so much noise for so little !&lt;BR /&gt;
Many thanks&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2016 13:52:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/is-supported-in-regex-for-field-extraction/m-p/202987#M58952</guid>
      <dc:creator>lauMarot</dc:creator>
      <dc:date>2016-08-03T13:52:54Z</dc:date>
    </item>
  </channel>
</rss>

