<?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 is the splunk eval case with special characters  not working? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-is-the-splunk-eval-case-with-special-characters-not-working/m-p/433913#M123883</link>
    <description>&lt;P&gt;@niketnilay : Its always good to have more than one approach:) &lt;/P&gt;</description>
    <pubDate>Tue, 10 Jul 2018 13:50:21 GMT</pubDate>
    <dc:creator>Chandras11</dc:creator>
    <dc:date>2018-07-10T13:50:21Z</dc:date>
    <item>
      <title>Why is the splunk eval case with special characters  not working?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-the-splunk-eval-case-with-special-characters-not-working/m-p/433908#M123878</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;

&lt;P&gt;when I try to use the following command, it always gives in CA_flag as "Other" although lower_Ticket_Desc has a exact maching term. Is there something, which I am not doing correctly here :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval lower_Ticket_Desc = lower(TICKET_DESC)| rex field=lower_Ticket_Desc mode=sed "s/ //g"|eval CA_flag = case(lower_Ticket_Desc=="[yes/no]:no" ,"Flag_NO" ,lower_Ticket_Desc=="[yes/no]:yes"  ,"Flag_YES" , 1=1, "Other" )  | 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have removed all blank spaces and converted everything to lower case.&lt;BR /&gt;&lt;BR /&gt;
TICKET_DESC example = "asdfjkasdhf [Yes/No]: No dfasjaskl" Or "asdfjkasdhf [Yes/No]:no asdfadsf"  or "asdfjkasdhf [Yes/No]: YES asdfadsf"&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:24:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-the-splunk-eval-case-with-special-characters-not-working/m-p/433908#M123878</guid>
      <dc:creator>Chandras11</dc:creator>
      <dc:date>2020-09-29T20:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the splunk eval case with special characters  not working?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-the-splunk-eval-case-with-special-characters-not-working/m-p/433909#M123879</link>
      <description>&lt;P&gt;That's because your case statement uses == comparison operator, which requires an exact match. While your match string is a substring of the actual field value.&lt;/P&gt;

&lt;P&gt;Try the following using like() and adding % signs before and after the match string:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval lower_Ticket_Desc = lower(TICKET_DESC) 
| rex field=lower_Ticket_Desc mode=sed "s/ //g" 
| eval CA_flag = case(like(lower_Ticket_Desc,"%[yes/no]:no%") ,"Flag_NO" ,like(lower_Ticket_Desc,"%[yes/no]:yes%") ,"Flag_YES" , 1=1, "Other" )
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Jul 2018 13:29:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-the-splunk-eval-case-with-special-characters-not-working/m-p/433909#M123879</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2018-07-10T13:29:48Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the splunk eval case with special characters  not working?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-the-splunk-eval-case-with-special-characters-not-working/m-p/433910#M123880</link>
      <description>&lt;P&gt;Thanks Frank.. you reduced one common mistake, which I do regularly &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt;</description>
      <pubDate>Tue, 10 Jul 2018 13:39:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-the-splunk-eval-case-with-special-characters-not-working/m-p/433910#M123880</guid>
      <dc:creator>Chandras11</dc:creator>
      <dc:date>2018-07-10T13:39:46Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the splunk eval case with special characters  not working?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-the-splunk-eval-case-with-special-characters-not-working/m-p/433911#M123881</link>
      <description>&lt;P&gt;@Chandras11, please try the following &lt;CODE&gt;case()&lt;/CODE&gt; statement&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval CA_flag = case(match(lower_Ticket_Desc,"^\[yes\/no\]:no$") ,"Flag_NO",
                     match(lower_Ticket_Desc,"^\[yes\/no\]:yes$") ,"Flag_YES",
                     1=1, "Other")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Following is a run anywhere search for testing:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval lower_Ticket_Desc="[yes/no]:yes" 
| eval CA_flag = case(match(lower_Ticket_Desc,"^\[yes\/no\]:no$") ,"Flag_NO",
                 match(lower_Ticket_Desc,"^\[yes\/no\]:yes$") ,"Flag_YES",
                 1=1, "Other")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Jul 2018 13:46:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-the-splunk-eval-case-with-special-characters-not-working/m-p/433911#M123881</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-07-10T13:46:57Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the splunk eval case with special characters  not working?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-the-splunk-eval-case-with-special-characters-not-working/m-p/433912#M123882</link>
      <description>&lt;P&gt;@FrankVl, nothing new... again you beat me to it. I posted a different approach but too late &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jul 2018 13:48:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-the-splunk-eval-case-with-special-characters-not-working/m-p/433912#M123882</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-07-10T13:48:02Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the splunk eval case with special characters  not working?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-the-splunk-eval-case-with-special-characters-not-working/m-p/433913#M123883</link>
      <description>&lt;P&gt;@niketnilay : Its always good to have more than one approach:) &lt;/P&gt;</description>
      <pubDate>Tue, 10 Jul 2018 13:50:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-the-splunk-eval-case-with-special-characters-not-working/m-p/433913#M123883</guid>
      <dc:creator>Chandras11</dc:creator>
      <dc:date>2018-07-10T13:50:21Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the splunk eval case with special characters  not working?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-the-splunk-eval-case-with-special-characters-not-working/m-p/433914#M123884</link>
      <description>&lt;P&gt;I don't think those regular expressions are correct, given that the field values look like this (according to his examples): "asdfjkasdhf [Yes/No]: No dfasjaskl"&lt;/P&gt;

&lt;P&gt;If your regex would have been correct, then his original == would also have worked, right?&lt;/P&gt;

&lt;P&gt;Just remove the &lt;CODE&gt;^&lt;/CODE&gt; and &lt;CODE&gt;$&lt;/CODE&gt; signs and it would work.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jul 2018 13:54:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-the-splunk-eval-case-with-special-characters-not-working/m-p/433914#M123884</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2018-07-10T13:54:44Z</dc:date>
    </item>
  </channel>
</rss>

