<?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 How to do the opposite of match()? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-do-the-opposite-of-match/m-p/241008#M71648</link>
    <description>&lt;P&gt;I'm trying to do a DOES NOT match() instead of a match(). &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.1/SearchReference/Commonevalfunctions"&gt;http://docs.splunk.com/Documentation/Splunk/6.1/SearchReference/Commonevalfunctions&lt;/A&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;match(SUBJECT, REGEX)

This function compares the regex string REGEX to the value of SUBJECT and returns a Boolean value; it returns true if the REGEX can find a match against any substring of SUBJECT.

his example returns true IF AND ONLY IF field matches the basic pattern of an IP address. Note that the example uses ^ and $ to perform a full match.
... | eval n=if(match(field, "^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$"), 1, 0)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For instance, I want something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval filteredhosts=mvfilter(DoesNotmatch(host, "giraffe")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Instead of this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval filteredhosts=mvfilter(match(host, "giraffe")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I feel like the solution should be obvious but I can't figure it out so far. Anyone?&lt;/P&gt;</description>
    <pubDate>Thu, 21 Jan 2016 19:24:26 GMT</pubDate>
    <dc:creator>thisissplunk</dc:creator>
    <dc:date>2016-01-21T19:24:26Z</dc:date>
    <item>
      <title>How to do the opposite of match()?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-do-the-opposite-of-match/m-p/241008#M71648</link>
      <description>&lt;P&gt;I'm trying to do a DOES NOT match() instead of a match(). &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.1/SearchReference/Commonevalfunctions"&gt;http://docs.splunk.com/Documentation/Splunk/6.1/SearchReference/Commonevalfunctions&lt;/A&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;match(SUBJECT, REGEX)

This function compares the regex string REGEX to the value of SUBJECT and returns a Boolean value; it returns true if the REGEX can find a match against any substring of SUBJECT.

his example returns true IF AND ONLY IF field matches the basic pattern of an IP address. Note that the example uses ^ and $ to perform a full match.
... | eval n=if(match(field, "^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$"), 1, 0)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For instance, I want something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval filteredhosts=mvfilter(DoesNotmatch(host, "giraffe")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Instead of this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval filteredhosts=mvfilter(match(host, "giraffe")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I feel like the solution should be obvious but I can't figure it out so far. Anyone?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jan 2016 19:24:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-do-the-opposite-of-match/m-p/241008#M71648</guid>
      <dc:creator>thisissplunk</dc:creator>
      <dc:date>2016-01-21T19:24:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to do the opposite of match()?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-do-the-opposite-of-match/m-p/241009#M71649</link>
      <description>&lt;P&gt;Have you tried this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval filteredhosts=mvfilter(if (NOT match(host, "giraffe"), "", host)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I don't have a Splunk instance here to tests this so it's just a guess. &lt;/P&gt;</description>
      <pubDate>Thu, 21 Jan 2016 19:55:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-do-the-opposite-of-match/m-p/241009#M71649</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-01-21T19:55:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to do the opposite of match()?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-do-the-opposite-of-match/m-p/241010#M71650</link>
      <description>&lt;P&gt;Hey thanks. That worked!&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jan 2016 20:09:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-do-the-opposite-of-match/m-p/241010#M71650</guid>
      <dc:creator>thisissplunk</dc:creator>
      <dc:date>2016-01-21T20:09:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to do the opposite of match()?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-do-the-opposite-of-match/m-p/577165#M201140</link>
      <description>&lt;P&gt;If anyone is coming across this in version 8 of splunk, the expression given by the answer may not work. In this case, use negative lookaheads, which is more reliable:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval filteredhosts=mvfilter(match(host, "^(?!giraffe).+$"))&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 03 Dec 2021 01:23:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-do-the-opposite-of-match/m-p/577165#M201140</guid>
      <dc:creator>haraksin</dc:creator>
      <dc:date>2021-12-03T01:23:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to do the opposite of match()?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-do-the-opposite-of-match/m-p/631782#M219445</link>
      <description>&lt;P&gt;This is an old post, but figured this might help someone out if they're trying to do the same thing.&lt;/P&gt;&lt;P&gt;You can use the not ! operator.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval filteredhosts=mvfilter(!match(host, "giraffe"))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;This works for me.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2023 04:34:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-do-the-opposite-of-match/m-p/631782#M219445</guid>
      <dc:creator>jacobappleton</dc:creator>
      <dc:date>2023-02-22T04:34:12Z</dc:date>
    </item>
  </channel>
</rss>

