<?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: Why won't my multiple &amp;quot;eval if match&amp;quot; expressions work? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-won-t-my-multiple-quot-eval-if-match-quot-expressions-work/m-p/282099#M85145</link>
    <description>&lt;P&gt;I understand the bad overwrite now. Thanks.&lt;/P&gt;</description>
    <pubDate>Fri, 16 Oct 2015 19:34:40 GMT</pubDate>
    <dc:creator>jsven7</dc:creator>
    <dc:date>2015-10-16T19:34:40Z</dc:date>
    <item>
      <title>Why won't my multiple "eval if match" expressions work?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-won-t-my-multiple-quot-eval-if-match-quot-expressions-work/m-p/282086#M85132</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;I'm trying to check a field for an OS. If Windows, then replace the entire field with "Windows". If mac is found, then replace the entire field with "Mac" Etc. It seems like only the second match works. Anyone know why?&lt;/P&gt;

&lt;P&gt;Current Search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...
| eval OS=if(match(User_Agent,"mac"),"Macintosh",User_Agent)
| eval OS=if(match(User_Agent,"windows"),"Windows",User_Agent)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Sample Data:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; PRU_IE; rv:11.0) like Gecko
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/600.3.18 (KHTML, like Gecko) Version/8.0.3 Safari/600.3.18
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Oct 2015 17:21:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-won-t-my-multiple-quot-eval-if-match-quot-expressions-work/m-p/282086#M85132</guid>
      <dc:creator>jsven7</dc:creator>
      <dc:date>2015-10-16T17:21:12Z</dc:date>
    </item>
    <item>
      <title>Re: Why won't my multiple "eval if match" expressions work?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-won-t-my-multiple-quot-eval-if-match-quot-expressions-work/m-p/282087#M85133</link>
      <description>&lt;P&gt;Did you try capitalizing the m and w of mac and windows in your match function ? &lt;/P&gt;</description>
      <pubDate>Fri, 16 Oct 2015 17:51:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-won-t-my-multiple-quot-eval-if-match-quot-expressions-work/m-p/282087#M85133</guid>
      <dc:creator>aljohnson_splun</dc:creator>
      <dc:date>2015-10-16T17:51:29Z</dc:date>
    </item>
    <item>
      <title>Re: Why won't my multiple "eval if match" expressions work?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-won-t-my-multiple-quot-eval-if-match-quot-expressions-work/m-p/282088#M85134</link>
      <description>&lt;P&gt;You're matching on the field User_Agent for patterns like "mac" and windows".  So I ask, does the User_Agent field exist on "mac" data?  If so, can you please post example?  &lt;/P&gt;

&lt;P&gt;or you can show us what matches this search maybe? &lt;BR /&gt;
     ...|dedup User_Agent | table User_Agent&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 07:35:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-won-t-my-multiple-quot-eval-if-match-quot-expressions-work/m-p/282088#M85134</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2020-09-29T07:35:14Z</dc:date>
    </item>
    <item>
      <title>Re: Why won't my multiple "eval if match" expressions work?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-won-t-my-multiple-quot-eval-if-match-quot-expressions-work/m-p/282089#M85135</link>
      <description>&lt;P&gt;That was my first thought, but he says windows match is working so I asked for a list of User_Agent values.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Oct 2015 17:56:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-won-t-my-multiple-quot-eval-if-match-quot-expressions-work/m-p/282089#M85135</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2015-10-16T17:56:54Z</dc:date>
    </item>
    <item>
      <title>Re: Why won't my multiple "eval if match" expressions work?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-won-t-my-multiple-quot-eval-if-match-quot-expressions-work/m-p/282090#M85136</link>
      <description>&lt;P&gt;It 's looks like this?&lt;/P&gt;

&lt;P&gt;ex.)&lt;BR /&gt;
User_Agent："mac"&lt;/P&gt;

&lt;P&gt;| eval OS=if(match(User_Agent,"mac"),"Macintosh",User_Agent)&lt;BR /&gt;
OS:Macintosh&lt;BR /&gt;
| eval OS=if(match(User_Agent,"windows"),"Windows",User_Agent)&lt;BR /&gt;
OS:mac&lt;/P&gt;

&lt;P&gt;Try this!&lt;/P&gt;

&lt;P&gt;your search |eval OS = case(match(User_Agent,"mac"), "Macintosh", match(User_Agent,"windows"), "Windows",1==1,User_Agent)&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 07:35:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-won-t-my-multiple-quot-eval-if-match-quot-expressions-work/m-p/282090#M85136</guid>
      <dc:creator>HiroshiSatoh</dc:creator>
      <dc:date>2020-09-29T07:35:17Z</dc:date>
    </item>
    <item>
      <title>Re: Why won't my multiple "eval if match" expressions work?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-won-t-my-multiple-quot-eval-if-match-quot-expressions-work/m-p/282091#M85137</link>
      <description>&lt;P&gt;You're writing the &lt;CODE&gt;OS&lt;/CODE&gt; field in the second &lt;CODE&gt;eval&lt;/CODE&gt;, regardless of a match or not: Either with &lt;CODE&gt;"Windows"&lt;/CODE&gt; or with &lt;CODE&gt;User_Agent&lt;/CODE&gt;. Instead, make the &lt;CODE&gt;if()&lt;/CODE&gt; preserve the current value like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...
| eval OS=if(match(User_Agent,"(?i)mac"),"Macintosh",OS)
| eval OS=if(match(User_Agent,"(?i)windows"),"Windows",OS)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note that I made the regular expressions case insensitive. Additionally, be careful about accidentally matching other parts of the string. I'm pretty sure the web already has working examples of how to regex out the OS from a user agent, maybe even on splunkbase.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Oct 2015 18:19:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-won-t-my-multiple-quot-eval-if-match-quot-expressions-work/m-p/282091#M85137</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2015-10-16T18:19:52Z</dc:date>
    </item>
    <item>
      <title>Re: Why won't my multiple "eval if match" expressions work?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-won-t-my-multiple-quot-eval-if-match-quot-expressions-work/m-p/282092#M85138</link>
      <description>&lt;P&gt;They are both working, but your second eval is overwriting the OS value of your first.   &lt;/P&gt;

&lt;P&gt;Change the second to:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| eval OS=if(match(User_Agent,"windows"),"Windows",OS)&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Oct 2015 18:23:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-won-t-my-multiple-quot-eval-if-match-quot-expressions-work/m-p/282092#M85138</guid>
      <dc:creator>DeronJensen</dc:creator>
      <dc:date>2015-10-16T18:23:25Z</dc:date>
    </item>
    <item>
      <title>Re: Why won't my multiple "eval if match" expressions work?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-won-t-my-multiple-quot-eval-if-match-quot-expressions-work/m-p/282093#M85139</link>
      <description>&lt;P&gt;Sorry, the sample data is raw. In the code I had the sample data all lowercased.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Oct 2015 18:42:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-won-t-my-multiple-quot-eval-if-match-quot-expressions-work/m-p/282093#M85139</guid>
      <dc:creator>jsven7</dc:creator>
      <dc:date>2015-10-16T18:42:33Z</dc:date>
    </item>
    <item>
      <title>Re: Why won't my multiple "eval if match" expressions work?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-won-t-my-multiple-quot-eval-if-match-quot-expressions-work/m-p/282094#M85140</link>
      <description>&lt;P&gt;Sorry I don't understand your question. Are you asking if there is a User_Agent field that contains the literals, 'mac'? If so yes. &lt;/P&gt;

&lt;P&gt;Below is a field where with the above code I expect it to be 'Macintosh' because of the literal 'mac' contained in it.&lt;BR /&gt;
junospulseipad/iphone mozilla/5.0 (ipad; cpu os 9_0_2 like &lt;STRONG&gt;mac&lt;/STRONG&gt; os x) applewebkit/601.1.46 (khtml, like gecko) mobile/13a452 junospulse(version-5.0.8.50589)ipad/iphone &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 07:37:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-won-t-my-multiple-quot-eval-if-match-quot-expressions-work/m-p/282094#M85140</guid>
      <dc:creator>jsven7</dc:creator>
      <dc:date>2020-09-29T07:37:41Z</dc:date>
    </item>
    <item>
      <title>Re: Why won't my multiple "eval if match" expressions work?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-won-t-my-multiple-quot-eval-if-match-quot-expressions-work/m-p/282095#M85141</link>
      <description>&lt;P&gt;BOOM ! This is the answer.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Oct 2015 19:09:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-won-t-my-multiple-quot-eval-if-match-quot-expressions-work/m-p/282095#M85141</guid>
      <dc:creator>aljohnson_splun</dc:creator>
      <dc:date>2015-10-16T19:09:33Z</dc:date>
    </item>
    <item>
      <title>Re: Why won't my multiple "eval if match" expressions work?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-won-t-my-multiple-quot-eval-if-match-quot-expressions-work/m-p/282096#M85142</link>
      <description>&lt;P&gt;Ok. I understand that I'm having a logic issue. I don't see it though. This example works as I want to use it for multiple matches. Appreciate it.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Oct 2015 19:30:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-won-t-my-multiple-quot-eval-if-match-quot-expressions-work/m-p/282096#M85142</guid>
      <dc:creator>jsven7</dc:creator>
      <dc:date>2015-10-16T19:30:18Z</dc:date>
    </item>
    <item>
      <title>Re: Why won't my multiple "eval if match" expressions work?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-won-t-my-multiple-quot-eval-if-match-quot-expressions-work/m-p/282097#M85143</link>
      <description>&lt;P&gt;Thank you HiroshiSatoh. This works. Only thing is that I tried to copy-cat the logic for multiple searches and I ran into issues. I'm new to Splunk! &lt;/P&gt;</description>
      <pubDate>Fri, 16 Oct 2015 19:32:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-won-t-my-multiple-quot-eval-if-match-quot-expressions-work/m-p/282097#M85143</guid>
      <dc:creator>jsven7</dc:creator>
      <dc:date>2015-10-16T19:32:06Z</dc:date>
    </item>
    <item>
      <title>Re: Why won't my multiple "eval if match" expressions work?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-won-t-my-multiple-quot-eval-if-match-quot-expressions-work/m-p/282098#M85144</link>
      <description>&lt;P&gt;Everyone said, "your overwriting". For some reason when I read your "you're overwriting" the light bulb turned on. Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Oct 2015 19:33:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-won-t-my-multiple-quot-eval-if-match-quot-expressions-work/m-p/282098#M85144</guid>
      <dc:creator>jsven7</dc:creator>
      <dc:date>2015-10-16T19:33:52Z</dc:date>
    </item>
    <item>
      <title>Re: Why won't my multiple "eval if match" expressions work?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-won-t-my-multiple-quot-eval-if-match-quot-expressions-work/m-p/282099#M85145</link>
      <description>&lt;P&gt;I understand the bad overwrite now. Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Oct 2015 19:34:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-won-t-my-multiple-quot-eval-if-match-quot-expressions-work/m-p/282099#M85145</guid>
      <dc:creator>jsven7</dc:creator>
      <dc:date>2015-10-16T19:34:40Z</dc:date>
    </item>
    <item>
      <title>Re: Why won't my multiple "eval if match" expressions work?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-won-t-my-multiple-quot-eval-if-match-quot-expressions-work/m-p/282100#M85146</link>
      <description>&lt;P&gt;This works for me, thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 22 Nov 2018 10:53:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-won-t-my-multiple-quot-eval-if-match-quot-expressions-work/m-p/282100#M85146</guid>
      <dc:creator>becksyboy</dc:creator>
      <dc:date>2018-11-22T10:53:15Z</dc:date>
    </item>
  </channel>
</rss>

