<?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 field != expression not matching in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regex-field-expression-not-matching/m-p/282887#M85441</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I think you may need to double-escape the backslash in your second regex. As a test, I tried this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval field1="api.twitter.com"
| eval field2="ABC\xyz1aul4"
| regex field2!="(?i)abc\\\xyz[a-z0-9]{5}"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Which worked (i.e. it returned no results).&lt;/P&gt;

&lt;P&gt;Likewise just invert the logic to see if it does match:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| regex field2="(?i)abc\\\xyz[a-z0-9]{5}"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;See if that does it.&lt;/P&gt;</description>
    <pubDate>Thu, 09 Feb 2017 06:39:03 GMT</pubDate>
    <dc:creator>gvmorley</dc:creator>
    <dc:date>2017-02-09T06:39:03Z</dc:date>
    <item>
      <title>Regex field != expression not matching</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-field-expression-not-matching/m-p/282884#M85438</link>
      <description>&lt;P&gt;I have a query where I am performing regex matching on two different fields, field1 and field2. &lt;CODE&gt;index=proxylogs uri!=aa.*|regex field1=".*abc\..*|.*api\..*"|regex field2!="(?i)abc\\xyz[a-z0-9]{5}|(?i)abc\\kkr[a-z0-9]{6}"|...&lt;/CODE&gt;. Field 1 matches with the regex pattern and provides results that have matching values. However, field 2 doesn't work as I am getting the results that do match the regex of field2 and not discarding them. According to the '!=', the values that match that particular regex  shouldn't be present in the result of the query, but they are. So, it isn't working as it supposed to. I have tested the regex elsewhere and it is correct. Any ideas? &lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 00:19:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-field-expression-not-matching/m-p/282884#M85438</guid>
      <dc:creator>raghav130593</dc:creator>
      <dc:date>2017-02-09T00:19:32Z</dc:date>
    </item>
    <item>
      <title>Re: Regex field != expression not matching</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-field-expression-not-matching/m-p/282885#M85439</link>
      <description>&lt;P&gt;Can you post an example event please? One that should be filtered out by the second regex command but is not?&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 00:32:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-field-expression-not-matching/m-p/282885#M85439</guid>
      <dc:creator>lquinn</dc:creator>
      <dc:date>2017-02-09T00:32:54Z</dc:date>
    </item>
    <item>
      <title>Re: Regex field != expression not matching</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-field-expression-not-matching/m-p/282886#M85440</link>
      <description>&lt;P&gt;I used stats in the query so I have a statistics table with selected fields. So, an example of the result which shouldn't be there would be&lt;BR /&gt;
field1              field2&lt;BR /&gt;
api.twitter.com           ABC\xyz1aul4&lt;/P&gt;

&lt;P&gt;This should ideally be avoided since it matches the second field's regex but it hasn't&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 00:42:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-field-expression-not-matching/m-p/282886#M85440</guid>
      <dc:creator>raghav130593</dc:creator>
      <dc:date>2017-02-09T00:42:44Z</dc:date>
    </item>
    <item>
      <title>Re: Regex field != expression not matching</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-field-expression-not-matching/m-p/282887#M85441</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I think you may need to double-escape the backslash in your second regex. As a test, I tried this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval field1="api.twitter.com"
| eval field2="ABC\xyz1aul4"
| regex field2!="(?i)abc\\\xyz[a-z0-9]{5}"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Which worked (i.e. it returned no results).&lt;/P&gt;

&lt;P&gt;Likewise just invert the logic to see if it does match:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| regex field2="(?i)abc\\\xyz[a-z0-9]{5}"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;See if that does it.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 06:39:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-field-expression-not-matching/m-p/282887#M85441</guid>
      <dc:creator>gvmorley</dc:creator>
      <dc:date>2017-02-09T06:39:03Z</dc:date>
    </item>
    <item>
      <title>Re: Regex field != expression not matching</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-field-expression-not-matching/m-p/282888#M85442</link>
      <description>&lt;P&gt;Yup. That worked. Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2017 01:50:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-field-expression-not-matching/m-p/282888#M85442</guid>
      <dc:creator>raghav130593</dc:creator>
      <dc:date>2017-02-14T01:50:07Z</dc:date>
    </item>
  </channel>
</rss>

