<?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: Can I use regex within an IF statement? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Can-I-use-regex-within-an-IF-statement/m-p/451145#M127763</link>
    <description>&lt;P&gt;The way I do it is with match.&lt;/P&gt;

&lt;P&gt;| eval output = if(match(Object,"regex goes here"),"false", "empty")&lt;/P&gt;

&lt;P&gt;Or something along those lines.&lt;/P&gt;

&lt;P&gt;Does that make sense or help?&lt;/P&gt;</description>
    <pubDate>Wed, 18 Jul 2018 19:26:58 GMT</pubDate>
    <dc:creator>auraria1</dc:creator>
    <dc:date>2018-07-18T19:26:58Z</dc:date>
    <item>
      <title>Can I use regex within an IF statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-use-regex-within-an-IF-statement/m-p/451144#M127762</link>
      <description>&lt;P&gt;This is what I have so far:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval output = if (Object = "false", [rex field=_raw"(?s)(?.*)(?), "Empty"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I am trying to do is to perform a regex on a line if the value of the object is false. The reason I'm doing this is because I have an xml file that, when generated, the output can be 1 of 2 things. depending the Object value is the rex that needs to be used (I will be changing the "Empty" tag for another rex if this is possible).&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jul 2018 19:19:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-use-regex-within-an-IF-statement/m-p/451144#M127762</guid>
      <dc:creator>albinortiz</dc:creator>
      <dc:date>2018-07-18T19:19:45Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use regex within an IF statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-use-regex-within-an-IF-statement/m-p/451145#M127763</link>
      <description>&lt;P&gt;The way I do it is with match.&lt;/P&gt;

&lt;P&gt;| eval output = if(match(Object,"regex goes here"),"false", "empty")&lt;/P&gt;

&lt;P&gt;Or something along those lines.&lt;/P&gt;

&lt;P&gt;Does that make sense or help?&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jul 2018 19:26:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-use-regex-within-an-IF-statement/m-p/451145#M127763</guid>
      <dc:creator>auraria1</dc:creator>
      <dc:date>2018-07-18T19:26:58Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use regex within an IF statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-use-regex-within-an-IF-statement/m-p/451146#M127764</link>
      <description>&lt;P&gt;No you can't, but you can do something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field=_raw "your reg ex 1 to extract &amp;lt;field1&amp;gt;" | rex field=_raw "your reg ex 2 to extract &amp;lt;field2&amp;gt;" 
| eval output=if(Object="false", field1, field2) 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Jul 2018 19:38:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-use-regex-within-an-IF-statement/m-p/451146#M127764</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-07-18T19:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use regex within an IF statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-use-regex-within-an-IF-statement/m-p/451147#M127765</link>
      <description>&lt;P&gt;Thanks both yours and the answer above worked. Thanks for all the help.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jul 2018 21:43:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-use-regex-within-an-IF-statement/m-p/451147#M127765</guid>
      <dc:creator>albinortiz</dc:creator>
      <dc:date>2018-07-18T21:43:00Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use regex within an IF statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-use-regex-within-an-IF-statement/m-p/451148#M127766</link>
      <description>&lt;P&gt;Thanks both yours and the answer below worked. Thanks for all the help. I've tried this one before but never thought I had to call the rex field command again.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jul 2018 21:43:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-use-regex-within-an-IF-statement/m-p/451148#M127766</guid>
      <dc:creator>albinortiz</dc:creator>
      <dc:date>2018-07-18T21:43:42Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use regex within an IF statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-use-regex-within-an-IF-statement/m-p/451149#M127767</link>
      <description>&lt;P&gt;No problem, glad I could help.&lt;/P&gt;

&lt;P&gt;Evals can be a bit tricky, always a fun time working through those switches.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jul 2018 17:46:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-use-regex-within-an-IF-statement/m-p/451149#M127767</guid>
      <dc:creator>auraria1</dc:creator>
      <dc:date>2018-07-19T17:46:42Z</dc:date>
    </item>
  </channel>
</rss>

