<?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: Does the rex command filter events if the regular expression fails to match in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Does-the-rex-command-filter-events-if-the-regular-expression/m-p/646972#M223935</link>
    <description>&lt;P&gt;You know, it would be great if the reference page in the online manual for "rex" indicated your answer.&lt;/P&gt;</description>
    <pubDate>Wed, 14 Jun 2023 12:49:36 GMT</pubDate>
    <dc:creator>otheus</dc:creator>
    <dc:date>2023-06-14T12:49:36Z</dc:date>
    <item>
      <title>Does the rex command filter events if the regular expression fails to match?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Does-the-rex-command-filter-events-if-the-regular-expression/m-p/464790#M191627</link>
      <description>&lt;P&gt;I'm trying to use a regular expression in a summary query. I want to get all events so that nothing is omitted and I can gather count statistics on all events, even if a regular expression fails to match in the &lt;CODE&gt;rex&lt;/CODE&gt; command.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2023 22:34:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Does-the-rex-command-filter-events-if-the-regular-expression/m-p/464790#M191627</guid>
      <dc:creator>entpnerd</dc:creator>
      <dc:date>2023-06-14T22:34:12Z</dc:date>
    </item>
    <item>
      <title>Re: Does the rex command filter events if the regular expression fails to match</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Does-the-rex-command-filter-events-if-the-regular-expression/m-p/464791#M191628</link>
      <description>&lt;P&gt;The &lt;CODE&gt;rex&lt;/CODE&gt; command will not filter or remove any events, even if the &lt;CODE&gt;rex&lt;/CODE&gt; doesn't match. The &lt;CODE&gt;regex&lt;/CODE&gt; command is used to filter and remove events based on a regular expression.&lt;/P&gt;

&lt;P&gt;If the &lt;CODE&gt;rex&lt;/CODE&gt; fails to match a field, that field won't be present in that event.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=foo | rex field=_raw "Hello (?&amp;lt;match&amp;gt;.*)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For this data, you'll get the following&lt;/P&gt;

&lt;TABLE&gt;&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH&gt;_raw&lt;/TH&gt;
&lt;TH&gt;match&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;Hello world!&lt;/TD&gt;
&lt;TD&gt;world!&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Goodbye for now&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;&lt;/TABLE&gt;

&lt;P&gt;You can then use the &lt;CODE&gt;fillnull&lt;/CODE&gt; command to put a default value in fields where the value is NULL.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=foo | rex field=_raw "Hello (?&amp;lt;match&amp;gt;.*)" | fillnull value="EMPTY" match
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Which will give you the following results&lt;/P&gt;

&lt;TABLE&gt;&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH&gt;_raw&lt;/TH&gt;
&lt;TH&gt;match&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;Hello world!&lt;/TD&gt;
&lt;TD&gt;world!&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Goodbye for now&lt;/TD&gt;
&lt;TD&gt;EMPTY&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Wed, 23 Oct 2019 03:08:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Does-the-rex-command-filter-events-if-the-regular-expression/m-p/464791#M191628</guid>
      <dc:creator>sduff_splunk</dc:creator>
      <dc:date>2019-10-23T03:08:50Z</dc:date>
    </item>
    <item>
      <title>Re: Does the rex command filter events if the regular expression fails to match</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Does-the-rex-command-filter-events-if-the-regular-expression/m-p/646972#M223935</link>
      <description>&lt;P&gt;You know, it would be great if the reference page in the online manual for "rex" indicated your answer.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2023 12:49:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Does-the-rex-command-filter-events-if-the-regular-expression/m-p/646972#M223935</guid>
      <dc:creator>otheus</dc:creator>
      <dc:date>2023-06-14T12:49:36Z</dc:date>
    </item>
  </channel>
</rss>

