<?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: How do I use an eval command with a case function with regex to separate the blank vs any character? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-an-eval-command-with-a-case-function-with-regex-to/m-p/407902#M117791</link>
    <description>&lt;P&gt;Instead of using &lt;CODE&gt;like&lt;/CODE&gt; in your &lt;CODE&gt;case&lt;/CODE&gt; statement, use &lt;CODE&gt;match&lt;/CODE&gt;.  The &lt;CODE&gt;match&lt;/CODE&gt; function accepts regular expressions.  For example,&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;eval Port_Flag= case(match(PORT_DESC,"PORT:  BackPort:.*"), "Flag_NO", match(PORT_DESC,"PORT: .*? BackPort:.*"), "Flag_YES",1=1,"Other")&lt;/CODE&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 30 Nov 2018 13:18:42 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2018-11-30T13:18:42Z</dc:date>
    <item>
      <title>How do I use an eval command with a case function with regex to separate the blank vs any character?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-an-eval-command-with-a-case-function-with-regex-to/m-p/407901#M117790</link>
      <description>&lt;P&gt;hi,&lt;/P&gt;

&lt;P&gt;I have a  field PORT_DESC with the values as:&lt;BR /&gt;
"somethings sdsa Device:XYZ PORT: 1.2.3 BackPort: 4.5.6   some other text"&lt;BR /&gt;
"somethings Othertext Device:       PORT:      BackPort:    some other text"&lt;BR /&gt;
Now I need to define a Port_Flag separating these values as:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval Port_Flag= case(like(PORT_DESC,"%PORT:  BackPort:%"), "Flag_NO",like(PORT_DESC,"%PORT: 1.2.3 BackPort:%"),"Flag_YES",1=1,"Other")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, the Port value can be anything such as 1.2.3 or CRMT or vw3d. &lt;/P&gt;

&lt;P&gt;How can I separate these values where either no Port value is given or some value is assigned? Any regular expression will also be a great help, which can define &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;PORT:[Anything 0-9 or A-Z or a-z $%&amp;amp;/()]  BackPort:
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:09:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-an-eval-command-with-a-case-function-with-regex-to/m-p/407901#M117790</guid>
      <dc:creator>Chandras11</dc:creator>
      <dc:date>2020-09-29T22:09:38Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use an eval command with a case function with regex to separate the blank vs any character?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-an-eval-command-with-a-case-function-with-regex-to/m-p/407902#M117791</link>
      <description>&lt;P&gt;Instead of using &lt;CODE&gt;like&lt;/CODE&gt; in your &lt;CODE&gt;case&lt;/CODE&gt; statement, use &lt;CODE&gt;match&lt;/CODE&gt;.  The &lt;CODE&gt;match&lt;/CODE&gt; function accepts regular expressions.  For example,&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;eval Port_Flag= case(match(PORT_DESC,"PORT:  BackPort:.*"), "Flag_NO", match(PORT_DESC,"PORT: .*? BackPort:.*"), "Flag_YES",1=1,"Other")&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 13:18:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-an-eval-command-with-a-case-function-with-regex-to/m-p/407902#M117791</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2018-11-30T13:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use an eval command with a case function with regex to separate the blank vs any character?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-an-eval-command-with-a-case-function-with-regex-to/m-p/407903#M117792</link>
      <description>&lt;P&gt;Thanks for the info. However, .*? take everything. How can I remove not 1 but any number fo space characters there?  &lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 13:42:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-an-eval-command-with-a-case-function-with-regex-to/m-p/407903#M117792</guid>
      <dc:creator>Chandras11</dc:creator>
      <dc:date>2018-11-30T13:42:39Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use an eval command with a case function with regex to separate the blank vs any character?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-an-eval-command-with-a-case-function-with-regex-to/m-p/407904#M117793</link>
      <description>&lt;P&gt;Try: PORT: [^ ]+ BackPort:&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 15:26:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-an-eval-command-with-a-case-function-with-regex-to/m-p/407904#M117793</guid>
      <dc:creator>whrg</dc:creator>
      <dc:date>2018-11-30T15:26:25Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use an eval command with a case function with regex to separate the blank vs any character?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-an-eval-command-with-a-case-function-with-regex-to/m-p/407905#M117794</link>
      <description>&lt;P&gt;&lt;CODE&gt;.*?&lt;/CODE&gt; is non-greedy and should stop at " BackPort".  &lt;CODE&gt;\S+&lt;/CODE&gt; is an alterative (perhaps a better one).&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 17:55:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-an-eval-command-with-a-case-function-with-regex-to/m-p/407905#M117794</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2018-11-30T17:55:44Z</dc:date>
    </item>
  </channel>
</rss>

