<?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 Regex not accepted when searching in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regex-not-accepted-when-searching/m-p/327671#M97541</link>
    <description>&lt;P&gt;Hi guys,&lt;/P&gt;

&lt;P&gt;I am trying to get a regex to just match if a process has been run from the C drive, root folder.&lt;/P&gt;

&lt;P&gt;I tried the following regex&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;regex New_Process_Name!="C:\\+[^\\\]+$"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but I still get all processes. The logic is simple: match only if there is no further "\" after "C:\".&lt;/P&gt;

&lt;P&gt;What am I doing wrong?&lt;/P&gt;</description>
    <pubDate>Tue, 05 Dec 2017 10:46:16 GMT</pubDate>
    <dc:creator>robettinger</dc:creator>
    <dc:date>2017-12-05T10:46:16Z</dc:date>
    <item>
      <title>Regex not accepted when searching</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-not-accepted-when-searching/m-p/327671#M97541</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;

&lt;P&gt;I am trying to get a regex to just match if a process has been run from the C drive, root folder.&lt;/P&gt;

&lt;P&gt;I tried the following regex&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;regex New_Process_Name!="C:\\+[^\\\]+$"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but I still get all processes. The logic is simple: match only if there is no further "\" after "C:\".&lt;/P&gt;

&lt;P&gt;What am I doing wrong?&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2017 10:46:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-not-accepted-when-searching/m-p/327671#M97541</guid>
      <dc:creator>robettinger</dc:creator>
      <dc:date>2017-12-05T10:46:16Z</dc:date>
    </item>
    <item>
      <title>Re: Regex not accepted when searching</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-not-accepted-when-searching/m-p/327672#M97542</link>
      <description>&lt;P&gt;tested and its working fine.. &lt;BR /&gt;
Please check this - &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| regex New_Process_Name="C:[//\\\][^\\\]"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/3967i22A2CBAE96939EAD/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;BR /&gt;
&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/3968i53F2EDD5E26854C1/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2017 11:55:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-not-accepted-when-searching/m-p/327672#M97542</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2017-12-05T11:55:05Z</dc:date>
    </item>
    <item>
      <title>Re: Regex not accepted when searching</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-not-accepted-when-searching/m-p/327673#M97543</link>
      <description>&lt;P&gt;Hi @robettinger,&lt;/P&gt;

&lt;P&gt;Please try below query, in below query first lines generating dummy data. Replace &lt;CODE&gt;_raw&lt;/CODE&gt; in rex command with actual field name in which your processname stores.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval _raw="C:\abc.exe"
| append [ | makeresults | eval _raw="C:\abc\xyz.exe"]
| append [ | makeresults | eval _raw="C:\abc\pqr\xyz.exe"]
| rex field=_raw "(?m)C:[\\\](?&amp;lt;process&amp;gt;.*?[\\\].*)$"
| where isnull(process)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I hope this helps.&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Harshil&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2017 12:28:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-not-accepted-when-searching/m-p/327673#M97543</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2017-12-05T12:28:28Z</dc:date>
    </item>
    <item>
      <title>Re: Regex not accepted when searching</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-not-accepted-when-searching/m-p/327674#M97544</link>
      <description>&lt;P&gt;Hmmmm. Thank you! That is some improvement, but not quite yet what I had in mind .... Let me paste my entire query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=win_sec EventCode=4688 earliest=-1h@h latest=now New_Process_Name="C:\\Temp*" OR New_Process_Name="*AppData\\Local\\Temp*"  OR #########
| eval Account_Name=mvindex(Account_Name,0)
| eval Account_Domain=mvindex(Account_Domain,0)
| table _time, host, Account_Domain, Account_Name, app, New_Process_Name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The ##### part should be where New_Process_Name is something like "C:\xxx.xxx" &lt;STRONG&gt;but not&lt;/STRONG&gt; "C:\xxx\xxx.xxx"&lt;/P&gt;

&lt;P&gt;Your query makes sense but it's also renaming the New_Process_Name field which is not my intention ... Any ideas?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:08:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-not-accepted-when-searching/m-p/327674#M97544</guid>
      <dc:creator>robettinger</dc:creator>
      <dc:date>2020-09-29T17:08:23Z</dc:date>
    </item>
    <item>
      <title>Re: Regex not accepted when searching</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-not-accepted-when-searching/m-p/327675#M97545</link>
      <description>&lt;P&gt;ok, can you please try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval New_Process_Name="C:\abc.exe"
| append [ | makeresults | eval New_Process_Name="C:\abc\xyz.exe"]
| append [ | makeresults | eval New_Process_Name="C:\abc\pqr\xyz.exe"]
| append [ | makeresults | eval New_Process_Name="C:\Temp\xyz.exe"]
| append [ | makeresults | eval New_Process_Name="C:\abc\AppData\Local\Temp\xyz.exe"]
| rex field=New_Process_Name "(?m)(?&amp;lt;process&amp;gt;C:\\\(?!Temp|.*\\\AppData\\\Local\\\Temp\\\).*?\\\.*)$"
| where isnull(process)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So your query will be&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    index=win_sec EventCode=4688 earliest=-1h@h latest=now 
     | rex field=New_Process_Name "(?m)(?&amp;lt;process&amp;gt;C:\\\(?!Temp|.*\\\AppData\\\Local\\\Temp\\\).*?\\\.*)$"
     | where isnull(process)
     | eval Account_Name=mvindex(Account_Name,0)
     | eval Account_Domain=mvindex(Account_Domain,0)
     | table _time, host, Account_Domain, Account_Name, app, New_Process_Name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;EDIT: Updated the query&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2017 13:20:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-not-accepted-when-searching/m-p/327675#M97545</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2017-12-05T13:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: Regex not accepted when searching</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-not-accepted-when-searching/m-p/327676#M97546</link>
      <description>&lt;P&gt;I think you had the right idea, but I'm not a fan of escaping backslashes with rex/regex.  Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| regex New_Process_Name="^C:\x5c[^\x5c]+$"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Dec 2017 15:10:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-not-accepted-when-searching/m-p/327676#M97546</guid>
      <dc:creator>wenthold</dc:creator>
      <dc:date>2017-12-08T15:10:49Z</dc:date>
    </item>
  </channel>
</rss>

