<?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 Why is subsearch not working with regex? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-is-subsearch-not-working-with-regex/m-p/639557#M221604</link>
    <description>&lt;P&gt;I'm attempting to find file downloads within a 2 minute timespan following a browser being spawned from outlook (my subsearch). Everything works find (the search andsubsearch) until I add the regex command limiting the filepath to the downloads folder.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm getting the error "&lt;SPAN&gt;Error in 'SearchOperator:regex': Usage: regex &amp;lt;field&amp;gt; (=|!=) &amp;lt;regex&amp;gt;."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Can anyone help me understand why the regex command is throwing it off? I think it's because it's taking the subsearch as part of the regex syntax but I don't know how to separate the two.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Search:&lt;/P&gt;
&lt;P&gt;index=random_index event_simpleName=*FileWritten&lt;BR /&gt;| regex TargetFileName="^[\WD]\w*\S*\W(?:Users)\W\w+\.\w+\W(?:Downloads)\W\w+"&lt;BR /&gt;[search index=random_index* sourcetype=stuff event_simpleName=ProcessRollup* ParentBaseFileName=OUTLOOK.EXE ImageFileName IN (*firefox* *chrome* *edge*) CommandLine IN (*sharepoint.com*) NOT CommandLine IN (*vendor*)&lt;BR /&gt;| rename _time AS earliest&lt;BR /&gt;| eval latest=relative_time(_time,"+5min@min")&lt;BR /&gt;| table aid earliest latest&lt;BR /&gt;| format]&lt;BR /&gt;| table _time aid TargetFileName&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 11 Apr 2023 22:02:36 GMT</pubDate>
    <dc:creator>asaphappy</dc:creator>
    <dc:date>2023-04-11T22:02:36Z</dc:date>
    <item>
      <title>Why is subsearch not working with regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-subsearch-not-working-with-regex/m-p/639557#M221604</link>
      <description>&lt;P&gt;I'm attempting to find file downloads within a 2 minute timespan following a browser being spawned from outlook (my subsearch). Everything works find (the search andsubsearch) until I add the regex command limiting the filepath to the downloads folder.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm getting the error "&lt;SPAN&gt;Error in 'SearchOperator:regex': Usage: regex &amp;lt;field&amp;gt; (=|!=) &amp;lt;regex&amp;gt;."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Can anyone help me understand why the regex command is throwing it off? I think it's because it's taking the subsearch as part of the regex syntax but I don't know how to separate the two.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Search:&lt;/P&gt;
&lt;P&gt;index=random_index event_simpleName=*FileWritten&lt;BR /&gt;| regex TargetFileName="^[\WD]\w*\S*\W(?:Users)\W\w+\.\w+\W(?:Downloads)\W\w+"&lt;BR /&gt;[search index=random_index* sourcetype=stuff event_simpleName=ProcessRollup* ParentBaseFileName=OUTLOOK.EXE ImageFileName IN (*firefox* *chrome* *edge*) CommandLine IN (*sharepoint.com*) NOT CommandLine IN (*vendor*)&lt;BR /&gt;| rename _time AS earliest&lt;BR /&gt;| eval latest=relative_time(_time,"+5min@min")&lt;BR /&gt;| table aid earliest latest&lt;BR /&gt;| format]&lt;BR /&gt;| table _time aid TargetFileName&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2023 22:02:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-subsearch-not-working-with-regex/m-p/639557#M221604</guid>
      <dc:creator>asaphappy</dc:creator>
      <dc:date>2023-04-11T22:02:36Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch not working with regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-subsearch-not-working-with-regex/m-p/639560#M221607</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/255757"&gt;@asaphappy&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The regex command will only filter results that match or not match (!=) the regular expression.&amp;nbsp;Try removing the non capture group syntax and see if it helps, i.e.&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;| regex TargetFileName="^[\WD]\w*\S*\WUsers\W\w+\.\w+\WDownloads\W\w+"&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;If you are looking to use capture groups to pull fields out then use the &lt;STRONG&gt;rex&lt;/STRONG&gt; command instead.&lt;BR /&gt;&lt;BR /&gt;Hope that helps&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2023 21:19:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-subsearch-not-working-with-regex/m-p/639560#M221607</guid>
      <dc:creator>yeahnah</dc:creator>
      <dc:date>2023-04-11T21:19:21Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch not working with regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-subsearch-not-working-with-regex/m-p/639561#M221608</link>
      <description>&lt;P&gt;Thanks for the reply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;That regex string actually works -- I tried the primary search alone and it did pull back all the results I was looking for. I did attempt to change the regex to the method you suggested but that still gave me the same error.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2023 21:23:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-subsearch-not-working-with-regex/m-p/639561#M221608</guid>
      <dc:creator>asaphappy</dc:creator>
      <dc:date>2023-04-11T21:23:08Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch not working with regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-subsearch-not-working-with-regex/m-p/639563#M221609</link>
      <description>&lt;P&gt;Ah yes, I had a closer look at your SPL query and see what your mean (hint: use the Insert/Edit code sample when adding SPL as it helps in readability.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yeahnah_0-1681248284530.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/24866i692C51B46AA9BF21/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yeahnah_0-1681248284530.png" alt="yeahnah_0-1681248284530.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Anyway, as you suspected the regex should come after the subsearch, which I suspect is supposed to be a filter for the base search.&amp;nbsp; So something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=random_index event_simpleName=*FileWritten [search index=random_index* sourcetype=stuff event_simpleName=ProcessRollup* ParentBaseFileName=OUTLOOK.EXE ImageFileName IN (*firefox* *chrome* *edge*) CommandLine IN (*sharepoint.com*) NOT CommandLine IN (*vendor*)
  | rename _time AS earliest
  | eval latest=relative_time(_time,"+5min@min")
  | table aid earliest latest
  | format ]
| regex TargetFileName="^[\WD]\w*\S*\W(?:Users)\W\w+\.\w+\W(?:Downloads)\W\w+"
| table _time aid TargetFileName&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2023 21:26:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-subsearch-not-working-with-regex/m-p/639563#M221609</guid>
      <dc:creator>yeahnah</dc:creator>
      <dc:date>2023-04-11T21:26:22Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch not working with regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-subsearch-not-working-with-regex/m-p/639644#M221653</link>
      <description>&lt;P&gt;Sorry, this is my first time posting. I'll make sure to do that next time.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried your suggestion (moving the regex to after the subsearch) previously and the search returned with only the base search without the subsearch results fed into the base. So what I would see is all of the downloaded files of different users, but it should only be for that small subset of hosts that were seen spawning a browser from outlook.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2023 13:48:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-subsearch-not-working-with-regex/m-p/639644#M221653</guid>
      <dc:creator>asaphappy</dc:creator>
      <dc:date>2023-04-12T13:48:23Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch not working with regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-subsearch-not-working-with-regex/m-p/639648#M221654</link>
      <description>&lt;P&gt;Can you share some anonymised examples of events you would expect to keep and events you would expect to have been excluded by the regex. Please share in a code block &amp;lt;/&amp;gt; so we can copy them to test solutions with.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2023 14:05:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-subsearch-not-working-with-regex/m-p/639648#M221654</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-04-12T14:05:09Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch not working with regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-subsearch-not-working-with-regex/m-p/639655#M221658</link>
      <description>&lt;P&gt;Sure!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Events to keep:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;\Device\HarddiskVolume3\Users\jill.michaels\Downloads\46.pdf

\Device\HarddiskVolume3\Users\funny.bunny\Downloads\randomclientform.pdf

\Device\HarddiskVolume3\Users\miley.cyrus\Downloads\data\uber.jar&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Events to filter out&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;\Device\HarddiskVolume3\Users\random.user\AppData\Local\Temp\screenshot11913941210533618901.png

\Device\HarddiskVolume3\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroTextExtractor.exe&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 12 Apr 2023 15:23:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-subsearch-not-working-with-regex/m-p/639655#M221658</guid>
      <dc:creator>asaphappy</dc:creator>
      <dc:date>2023-04-12T15:23:54Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch not working with regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-subsearch-not-working-with-regex/m-p/639660#M221659</link>
      <description>&lt;P&gt;These events seem to be missing a number of significant fields:&amp;nbsp;event_simpleName, ParentBaseFileName, ImageFileName, CommandLine,&amp;nbsp;_time,&amp;nbsp;aid&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2023 15:41:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-subsearch-not-working-with-regex/m-p/639660#M221659</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-04-12T15:41:34Z</dc:date>
    </item>
    <item>
      <title>Re: Why is subsearch not working with regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-subsearch-not-working-with-regex/m-p/639701#M221673</link>
      <description>&lt;P&gt;The subsearch, as written, must be an argument to "| search"&amp;nbsp; so try this:&lt;BR /&gt;&lt;BR /&gt;index=random_index event_simpleName=*FileWritten&lt;BR /&gt;| regex TargetFileName="^[\WD]\w*\S*\W(?:Users)\W\w+\.\w+\W(?:Downloads)\W\w+"&lt;BR /&gt;| search [search index=random_index* sourcetype=stuff event_simpleName=ProcessRollup* ParentBaseFileName=OUTLOOK.EXE ImageFileName IN (*firefox* *chrome* *edge*) CommandLine IN (*sharepoint.com*) NOT CommandLine IN (*vendor*)&lt;BR /&gt;| rename _time AS earliest&lt;BR /&gt;| eval latest=relative_time(_time,"+5min@min")&lt;BR /&gt;| table aid earliest latest&lt;BR /&gt;| format]&lt;BR /&gt;| table _time aid TargetFileName&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2023 22:26:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-subsearch-not-working-with-regex/m-p/639701#M221673</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2023-04-12T22:26:03Z</dc:date>
    </item>
    <item>
      <title>Re: Why is subsearch not working with regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-subsearch-not-working-with-regex/m-p/639705#M221675</link>
      <description>&lt;P&gt;OK cool, I did not know that.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2023 22:36:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-subsearch-not-working-with-regex/m-p/639705#M221675</guid>
      <dc:creator>yeahnah</dc:creator>
      <dc:date>2023-04-12T22:36:08Z</dc:date>
    </item>
  </channel>
</rss>

