<?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 Is there a way to use regex on a standalone string to pull out each value, then append &amp;quot;field!=&amp;quot; to the front to exclude these values from a search? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-regex-on-a-standalone-string-to-pull-out/m-p/138877#M38149</link>
    <description>&lt;P&gt;I have a large list of values for a field that I would like to exclude from my search. Rather than having a huge search with:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;field!=value1
field!=value2
field!=value3
...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;is there a way to use regex to pull out each value and append &lt;CODE&gt;field!=&lt;/CODE&gt; to the front? As far as I can tell, Splunk can only use regex when parsing the entries themselves, not a standalone string.&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Mon, 27 Jul 2015 16:07:58 GMT</pubDate>
    <dc:creator>jlosee</dc:creator>
    <dc:date>2015-07-27T16:07:58Z</dc:date>
    <item>
      <title>Is there a way to use regex on a standalone string to pull out each value, then append "field!=" to the front to exclude these values from a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-regex-on-a-standalone-string-to-pull-out/m-p/138877#M38149</link>
      <description>&lt;P&gt;I have a large list of values for a field that I would like to exclude from my search. Rather than having a huge search with:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;field!=value1
field!=value2
field!=value3
...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;is there a way to use regex to pull out each value and append &lt;CODE&gt;field!=&lt;/CODE&gt; to the front? As far as I can tell, Splunk can only use regex when parsing the entries themselves, not a standalone string.&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jul 2015 16:07:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-regex-on-a-standalone-string-to-pull-out/m-p/138877#M38149</guid>
      <dc:creator>jlosee</dc:creator>
      <dc:date>2015-07-27T16:07:58Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to use regex on a standalone string to pull out each value, then append "field!=" to the front to exclude these values from a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-regex-on-a-standalone-string-to-pull-out/m-p/138878#M38150</link>
      <description>&lt;P&gt;Are you planning to do something like this (this subsearch will take a stand alon, comma separated string, and format it as an giant OR condition), a sample run anywhere query&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal  NOT [| gentimes start=-1 | eval sourcetype="splunk_web_access,splunkd_access,splunk_web_service" | makemv sourcetype delim="," | stats count by sourcetype | table sourcetype | format]  | stats count by sourcetype
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will remove all the events belongs to any of the sourcetype from splunk_web_access,splunkd_access,splunk_web_service.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 06:48:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-regex-on-a-standalone-string-to-pull-out/m-p/138878#M38150</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2020-09-29T06:48:59Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to use regex on a standalone string to pull out each value, then append "field!=" to the front to exclude these values from a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-regex-on-a-standalone-string-to-pull-out/m-p/138879#M38151</link>
      <description>&lt;P&gt;Not quite. Basically, I will have a list in an outside excel/word doc that I would want to copy &amp;amp; paste into a search and exclude those from the results. The plan is to do this in a macro for easier readability and modification when I want to use this list. Would makemv be able to help with that?&lt;/P&gt;

&lt;P&gt;Thanks for the quick response!&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jul 2015 17:52:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-regex-on-a-standalone-string-to-pull-out/m-p/138879#M38151</guid>
      <dc:creator>jlosee</dc:creator>
      <dc:date>2015-07-27T17:52:54Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to use regex on a standalone string to pull out each value, then append "field!=" to the front to exclude these values from a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-regex-on-a-standalone-string-to-pull-out/m-p/138880#M38152</link>
      <description>&lt;P&gt;If you copy past from the Excel/Word table into the search directly, is the values coming with line feed. Something like this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal NOT [| gentimes start=-1 | eval sourcetype="splunk_web_access
splunkd_access
splunk_web_service
" | eval sourcetype=replace(sourcetype,"\n",",") | makemv sourcetype delim="," | stats count by sourcetype | table sourcetype] | stats count by sourcetype
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Jul 2015 19:33:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-regex-on-a-standalone-string-to-pull-out/m-p/138880#M38152</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2015-07-27T19:33:17Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to use regex on a standalone string to pull out each value, then append "field!=" to the front to exclude these values from a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-regex-on-a-standalone-string-to-pull-out/m-p/138881#M38153</link>
      <description>&lt;P&gt;you can use eval to set a variable with the value of your string and then apply anything to it as if it is event data.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jul 2015 19:43:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-regex-on-a-standalone-string-to-pull-out/m-p/138881#M38153</guid>
      <dc:creator>mreynov_splunk</dc:creator>
      <dc:date>2015-07-27T19:43:38Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to use regex on a standalone string to pull out each value, then append "field!=" to the front to exclude these values from a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-regex-on-a-standalone-string-to-pull-out/m-p/138882#M38154</link>
      <description>&lt;P&gt;If I understand your question, then yes I believe each entry will be on its own line.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jul 2015 20:11:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-regex-on-a-standalone-string-to-pull-out/m-p/138882#M38154</guid>
      <dc:creator>jlosee</dc:creator>
      <dc:date>2015-07-28T20:11:15Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to use regex on a standalone string to pull out each value, then append "field!=" to the front to exclude these values from a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-regex-on-a-standalone-string-to-pull-out/m-p/138883#M38155</link>
      <description>&lt;P&gt;So will the format in which I wrote the thing for _internal data, works for your query? Try to run them in search bar first, if works fine, you saved the subsearch as macro and use the macro there&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jul 2015 20:17:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-regex-on-a-standalone-string-to-pull-out/m-p/138883#M38155</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2015-07-28T20:17:06Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to use regex on a standalone string to pull out each value, then append "field!=" to the front to exclude these values from a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-regex-on-a-standalone-string-to-pull-out/m-p/138884#M38156</link>
      <description>&lt;P&gt;In your new example, it looks like the results still include the three sourcetypes you listed (but I think the original example works right).&lt;/P&gt;

&lt;P&gt;I tried using your format with my code but the values I specify still show up in the results.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jul 2015 20:43:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-regex-on-a-standalone-string-to-pull-out/m-p/138884#M38156</guid>
      <dc:creator>jlosee</dc:creator>
      <dc:date>2015-07-28T20:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to use regex on a standalone string to pull out each value, then append "field!=" to the front to exclude these values from a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-regex-on-a-standalone-string-to-pull-out/m-p/138885#M38157</link>
      <description>&lt;P&gt;Thanks mreynov!&lt;/P&gt;

&lt;P&gt;So if I have &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval newField= "field!= value1 field!=value2 field!=value3...."
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Would I be able to use &lt;CODE&gt;rex&lt;/CODE&gt; or something else to have Splunk exclude those values?&lt;/P&gt;

&lt;P&gt;I'm also trying out somesoni2's method.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jul 2015 20:49:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-regex-on-a-standalone-string-to-pull-out/m-p/138885#M38157</guid>
      <dc:creator>jlosee</dc:creator>
      <dc:date>2015-07-28T20:49:45Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to use regex on a standalone string to pull out each value, then append "field!=" to the front to exclude these values from a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-regex-on-a-standalone-string-to-pull-out/m-p/138886#M38158</link>
      <description>&lt;P&gt;Ah I stand corrected--I left out the &lt;CODE&gt;gentimes start=-1&lt;/CODE&gt; because I thought that was specific to your example!&lt;/P&gt;

&lt;P&gt;So after some testing it looks like it does what I want it to do! I basically just used my code with your structure and it works great.&lt;/P&gt;

&lt;P&gt;I read up on gentimes but I still have a question: why was it necessary for this query to run correctly?&lt;/P&gt;

&lt;P&gt;Thanks again!&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jul 2015 23:18:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-regex-on-a-standalone-string-to-pull-out/m-p/138886#M38158</guid>
      <dc:creator>jlosee</dc:creator>
      <dc:date>2015-07-28T23:18:47Z</dc:date>
    </item>
  </channel>
</rss>

