<?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 not appearing to work in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regex-not-appearing-to-work/m-p/78138#M19772</link>
    <description>&lt;P&gt;mhale1982, I'm assuming that you want to use the field immediately following the timestamp as your host value?&lt;/P&gt;

&lt;P&gt;Try this regex with the rex command that Rob mentioned above.  So, in your case, it would be something like:&lt;/P&gt;

&lt;P&gt;your search goes here | rex ^(\S+\s+){3}(?&lt;AAAA&gt;[^\s]+)&lt;/AAAA&gt;&lt;/P&gt;

&lt;P&gt;And see if a field called "aaaa" gets extracted.  If so, the regex is good, and you can slap it into your host override.&lt;/P&gt;

&lt;P&gt;HTH&lt;/P&gt;</description>
    <pubDate>Fri, 04 Jan 2013 02:47:43 GMT</pubDate>
    <dc:creator>mloven_splunk</dc:creator>
    <dc:date>2013-01-04T02:47:43Z</dc:date>
    <item>
      <title>Regex not appearing to work</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-not-appearing-to-work/m-p/78136#M19770</link>
      <description>&lt;P&gt;I'm having some issues with using regex to define the host of some events from an ASA.  The events are in the format below:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;Jan  3 17:14:29 10.111.11.111 %ASA-6-302016: Teardown UDP connection 10101576 for external_untrusted:10.111.111.111/111 to external_untrusted:10.111.111.111/111 duration 0:00:00 bytes 0 (asdfasdf)&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I'm using the following regex:  &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b)?&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;This works fine here:  &lt;A href="http://regexpal.com/"&gt;Regex pal&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;But my event still shows:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;host=rel-splunk.roll.ad   |  sourcetype=cisco_asa   |  source=/var/log/syslog/asa&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Any thoughts on what I'm doing wrong?  &lt;/P&gt;</description>
      <pubDate>Fri, 04 Jan 2013 01:58:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-not-appearing-to-work/m-p/78136#M19770</guid>
      <dc:creator>mhale1982</dc:creator>
      <dc:date>2013-01-04T01:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: Regex not appearing to work</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-not-appearing-to-work/m-p/78137#M19771</link>
      <description>&lt;P&gt;Have you tried this regex with the Splunk 'rex' command?&lt;/P&gt;

&lt;P&gt;Also, I think you may have left out a space after the IP address. (This is assuming that you are looking for the first IP address from your sample event that follows the timestamp.)&lt;/P&gt;

&lt;P&gt;\b is a zero-width character assertion so your regex would be looking for the end of the IP address to have a new word immediately follow it which could become confusing depending on the regular expression engine.&lt;/P&gt;

&lt;P&gt;Try using (\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\s)? instead and see if that works out a bit better.&lt;/P&gt;

&lt;P&gt;I still recommend testing your regex with the Splunk search language as it will give you a better idea of how the regex is interpreted. E.g.&lt;/P&gt;

&lt;P&gt;|rex field=_raw "(?&lt;MYNEWFIELDNAME&gt;(?:\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\s)?)"&lt;/MYNEWFIELDNAME&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jan 2013 02:06:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-not-appearing-to-work/m-p/78137#M19771</guid>
      <dc:creator>Rob</dc:creator>
      <dc:date>2013-01-04T02:06:16Z</dc:date>
    </item>
    <item>
      <title>Re: Regex not appearing to work</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-not-appearing-to-work/m-p/78138#M19772</link>
      <description>&lt;P&gt;mhale1982, I'm assuming that you want to use the field immediately following the timestamp as your host value?&lt;/P&gt;

&lt;P&gt;Try this regex with the rex command that Rob mentioned above.  So, in your case, it would be something like:&lt;/P&gt;

&lt;P&gt;your search goes here | rex ^(\S+\s+){3}(?&lt;AAAA&gt;[^\s]+)&lt;/AAAA&gt;&lt;/P&gt;

&lt;P&gt;And see if a field called "aaaa" gets extracted.  If so, the regex is good, and you can slap it into your host override.&lt;/P&gt;

&lt;P&gt;HTH&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jan 2013 02:47:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-not-appearing-to-work/m-p/78138#M19772</guid>
      <dc:creator>mloven_splunk</dc:creator>
      <dc:date>2013-01-04T02:47:43Z</dc:date>
    </item>
    <item>
      <title>Re: Regex not appearing to work</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-not-appearing-to-work/m-p/78139#M19773</link>
      <description>&lt;P&gt;Nice regex!&lt;/P&gt;

&lt;P&gt;It also works well since if the first IP is the one we are looking for then the space character serves as a nice anchor. And it made me realize that my slashes are missing in my previous answer.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jan 2013 02:51:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-not-appearing-to-work/m-p/78139#M19773</guid>
      <dc:creator>Rob</dc:creator>
      <dc:date>2013-01-04T02:51:38Z</dc:date>
    </item>
    <item>
      <title>Re: Regex not appearing to work</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-not-appearing-to-work/m-p/78140#M19774</link>
      <description>&lt;P&gt;ah, weird, mine are too...  maybe some odd formatting going on...&lt;BR /&gt;
\test&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jan 2013 03:03:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-not-appearing-to-work/m-p/78140#M19774</guid>
      <dc:creator>mloven_splunk</dc:creator>
      <dc:date>2013-01-04T03:03:39Z</dc:date>
    </item>
    <item>
      <title>Re: Regex not appearing to work</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-not-appearing-to-work/m-p/78141#M19775</link>
      <description>&lt;P&gt;So mhale1982, there's some odd formatting going on that seems to be eating the backslashes from our responses, so, for clarity, I'll try to pop it into a code block to see if it accepts it, but there should be a backslash preceding each of the "s" or "S" characters.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your search goes here | rex ^(\S+\s+){3}(?&amp;lt;aaaa&amp;gt;[^\s]+)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 04 Jan 2013 03:07:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-not-appearing-to-work/m-p/78141#M19775</guid>
      <dc:creator>mloven_splunk</dc:creator>
      <dc:date>2013-01-04T03:07:20Z</dc:date>
    </item>
    <item>
      <title>Re: Regex not appearing to work</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-not-appearing-to-work/m-p/78142#M19776</link>
      <description>&lt;P&gt;All,&lt;/P&gt;

&lt;P&gt;Thanks for your replies so far.  I'm getting some issues running the expression using &lt;CODE&gt;rex field=_raw&lt;/CODE&gt;.  It does seem to give me some results if I use &lt;CODE&gt;regex _raw=&amp;lt;expression&amp;gt;&lt;/CODE&gt;.  I haven't tried using this in my data input section yet...that'll happen later today.  Will report back on how it works.  &lt;/P&gt;

&lt;P&gt;Thanks again!&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jan 2013 18:01:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-not-appearing-to-work/m-p/78142#M19776</guid>
      <dc:creator>mhale1982</dc:creator>
      <dc:date>2013-01-04T18:01:27Z</dc:date>
    </item>
    <item>
      <title>Re: Regex not appearing to work</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-not-appearing-to-work/m-p/78143#M19777</link>
      <description>&lt;P&gt;In case you haven't already checked it out, here is the docs link for rex: &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Rex"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Rex&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;For regex, its a little different:&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Regex"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Regex&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;The syntax is different for the two as you have noted as the rex command is used for extracting a field and the regex command is used for filtering results.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jan 2013 18:26:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-not-appearing-to-work/m-p/78143#M19777</guid>
      <dc:creator>Rob</dc:creator>
      <dc:date>2013-01-04T18:26:26Z</dc:date>
    </item>
    <item>
      <title>Re: Regex not appearing to work</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-not-appearing-to-work/m-p/78144#M19778</link>
      <description>&lt;P&gt;I just realized that I was doing something Splunk isn't designed for.  &lt;/P&gt;

&lt;P&gt;I was attempting to modify the 'hosts' value based on entries within the log.  What I failed to notice on the data input screen, the regex is based on the &lt;EM&gt;path&lt;/EM&gt; of the file, not the contents.  &lt;/P&gt;

&lt;P&gt;I've since modified rsyslog to log to files with the IP address as the name of the file and used the following regex to generate the host IP:  &lt;CODE&gt;(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b)&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Thanks again for the assistance and the info on regex and rex.  That'll be helpful moving forward.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jan 2013 22:37:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-not-appearing-to-work/m-p/78144#M19778</guid>
      <dc:creator>mhale1982</dc:creator>
      <dc:date>2013-01-04T22:37:53Z</dc:date>
    </item>
  </channel>
</rss>

