<?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 Regular Expression to Extract Values From a Field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205183#M59633</link>
    <description>&lt;P&gt;Hello Ninjas,&lt;/P&gt;

&lt;P&gt;Am having some trouble trying to figure out how to use regex to perform a simple action.&lt;/P&gt;

&lt;P&gt;So I have a field called Caller_Process_Name which has the value of &lt;CODE&gt;C:\Windows\System32\explorer.exe&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I want to take the "explorer.exe" part out of this field and place it in a new field (called process_name_short). So I see regex as the solution here.&lt;/P&gt;

&lt;P&gt;I have been trying the following but I do not believe I am using regex correctly in Splunk and the documentation isn't very helpful.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=Caller_Process_Name (?&amp;lt;process_name_short&amp;gt;/(\w+)\.(\w+)$/)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm sure my regex is solid as it pulls out only the explorer.exe part of the string in the online regex testers.&lt;/P&gt;

&lt;P&gt;Would anyone be willing to show me what I'm not doing right here please.&lt;/P&gt;

&lt;P&gt;Thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 08:15:34 GMT</pubDate>
    <dc:creator>Bytes</dc:creator>
    <dc:date>2020-09-29T08:15:34Z</dc:date>
    <item>
      <title>Regular Expression to Extract Values From a Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205183#M59633</link>
      <description>&lt;P&gt;Hello Ninjas,&lt;/P&gt;

&lt;P&gt;Am having some trouble trying to figure out how to use regex to perform a simple action.&lt;/P&gt;

&lt;P&gt;So I have a field called Caller_Process_Name which has the value of &lt;CODE&gt;C:\Windows\System32\explorer.exe&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I want to take the "explorer.exe" part out of this field and place it in a new field (called process_name_short). So I see regex as the solution here.&lt;/P&gt;

&lt;P&gt;I have been trying the following but I do not believe I am using regex correctly in Splunk and the documentation isn't very helpful.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=Caller_Process_Name (?&amp;lt;process_name_short&amp;gt;/(\w+)\.(\w+)$/)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm sure my regex is solid as it pulls out only the explorer.exe part of the string in the online regex testers.&lt;/P&gt;

&lt;P&gt;Would anyone be willing to show me what I'm not doing right here please.&lt;/P&gt;

&lt;P&gt;Thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 08:15:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205183#M59633</guid>
      <dc:creator>Bytes</dc:creator>
      <dc:date>2020-09-29T08:15:34Z</dc:date>
    </item>
    <item>
      <title>Re: Regular Expression to Extract Values From a Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205184#M59634</link>
      <description>&lt;P&gt;Your regular expression doesn't match the example value.  Working on regex101.com, I came up with this rex command.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field=Caller_Process_Name "\\(?&amp;lt;process_name_short&amp;gt;\w+\.\w+)$" | ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Jan 2016 16:18:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205184#M59634</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-01-04T16:18:04Z</dc:date>
    </item>
    <item>
      <title>Re: Regular Expression to Extract Values From a Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205185#M59635</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=Caller_Process_Name "\/(?&amp;lt;process_name_short&amp;gt;[^\/]+$)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Jan 2016 16:20:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205185#M59635</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-01-04T16:20:50Z</dc:date>
    </item>
    <item>
      <title>Re: Regular Expression to Extract Values From a Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205186#M59636</link>
      <description>&lt;P&gt;And the equivalent for Windows paths:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=Caller_Process_Name "\\\(?&amp;lt;process_name_short&amp;gt;[^\\\]+$)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Jan 2016 16:21:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205186#M59636</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-01-04T16:21:56Z</dc:date>
    </item>
    <item>
      <title>Re: Regular Expression to Extract Values From a Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205187#M59637</link>
      <description>&lt;P&gt;Hi you can use this.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | rex field=Caller_Process_Name "(?&amp;lt;process_name_short&amp;gt;[^\\]+$)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope i help you&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2016 16:23:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205187#M59637</guid>
      <dc:creator>jmallorquin</dc:creator>
      <dc:date>2016-01-04T16:23:44Z</dc:date>
    </item>
    <item>
      <title>Re: Regular Expression to Extract Values From a Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205188#M59638</link>
      <description>&lt;P&gt;Two questions off the top.&lt;BR /&gt;
Is it "C:/Windows/System32/explorer.exe" or &lt;CODE&gt;"C:\Windows\System32\explorer.exe"&lt;/CODE&gt; ?&lt;/P&gt;

&lt;P&gt;And are you enclosing your regular expression in quotes?&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2016 16:27:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205188#M59638</guid>
      <dc:creator>ArthurGautesen</dc:creator>
      <dc:date>2016-01-04T16:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: Regular Expression to Extract Values From a Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205189#M59639</link>
      <description>&lt;P&gt;Apologies. There should be back slashes instead of forward slashes in the UNC path. Had to use forward slashes on the question as it wouldn't allow back slashes.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2016 16:32:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205189#M59639</guid>
      <dc:creator>Bytes</dc:creator>
      <dc:date>2016-01-04T16:32:45Z</dc:date>
    </item>
    <item>
      <title>Re: Regular Expression to Extract Values From a Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205190#M59640</link>
      <description>&lt;P&gt;See my answer below. I did answer both cases&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2016 16:35:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205190#M59640</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-01-04T16:35:44Z</dc:date>
    </item>
    <item>
      <title>Re: Regular Expression to Extract Values From a Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205191#M59641</link>
      <description>&lt;P&gt;It should be back slashes as it is a normal Windows path. I added forward slashes as it wouldn't allow back slashes (as your answer shows &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; )&lt;/P&gt;

&lt;P&gt;I wasn't using quotes but even if I do, it still fails to extract the value and place it in a new field named process_name_short.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 08:15:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205191#M59641</guid>
      <dc:creator>Bytes</dc:creator>
      <dc:date>2020-09-29T08:15:37Z</dc:date>
    </item>
    <item>
      <title>Re: Regular Expression to Extract Values From a Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205192#M59642</link>
      <description>&lt;P&gt;Backslashes are allowed if you put the string within backtics.  I've edited your question to use the right slashes.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2016 16:40:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205192#M59642</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-01-04T16:40:25Z</dc:date>
    </item>
    <item>
      <title>Re: Regular Expression to Extract Values From a Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205193#M59643</link>
      <description>&lt;P&gt;Nope neither worked. Got the error returned:&lt;/P&gt;

&lt;P&gt;Error in 'rex' command: Encountered the following error while compiling the regex '\&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2016 16:41:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205193#M59643</guid>
      <dc:creator>Bytes</dc:creator>
      <dc:date>2016-01-04T16:41:35Z</dc:date>
    </item>
    <item>
      <title>Re: Regular Expression to Extract Values From a Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205194#M59644</link>
      <description>&lt;P&gt;That's because I made a typo sorry:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | rex field=Caller_Process_Name "\\\(?&amp;lt;process_name_short&amp;gt;[^\\\]+$)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Jan 2016 16:44:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205194#M59644</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-01-04T16:44:01Z</dc:date>
    </item>
    <item>
      <title>Re: Regular Expression to Extract Values From a Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205195#M59645</link>
      <description>&lt;P&gt;this regex doesn't capture nothing... use mine &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2016 16:44:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205195#M59645</guid>
      <dc:creator>jmallorquin</dc:creator>
      <dc:date>2016-01-04T16:44:23Z</dc:date>
    </item>
    <item>
      <title>Re: Regular Expression to Extract Values From a Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205196#M59646</link>
      <description>&lt;P&gt;Thank you! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2016 16:44:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205196#M59646</guid>
      <dc:creator>Bytes</dc:creator>
      <dc:date>2016-01-04T16:44:39Z</dc:date>
    </item>
    <item>
      <title>Re: Regular Expression to Extract Values From a Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205197#M59647</link>
      <description>&lt;P&gt;Quotes are required.  The extraction failed because the regex is incorrect.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2016 16:46:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205197#M59647</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-01-04T16:46:46Z</dc:date>
    </item>
    <item>
      <title>Re: Regular Expression to Extract Values From a Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205198#M59648</link>
      <description>&lt;P&gt;&lt;IMG src="http://i.imgur.com/PiFhSYS.png" alt="alt text" /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2016 16:52:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205198#M59648</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-01-04T16:52:59Z</dc:date>
    </item>
    <item>
      <title>Re: Regular Expression to Extract Values From a Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205199#M59649</link>
      <description>&lt;P&gt;You should only have two (not three) backslashes at the beginning of the REX and in side the Brackets after the ^.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2016 17:19:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205199#M59649</guid>
      <dc:creator>dcharboneau_spl</dc:creator>
      <dc:date>2016-01-04T17:19:38Z</dc:date>
    </item>
    <item>
      <title>Re: Regular Expression to Extract Values From a Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205200#M59650</link>
      <description>&lt;P&gt;It throws an error with two, I had to use three. See the picture above.&lt;BR /&gt;
This works:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count
| eval Caller_Process_Name = "C:\Windows\System32\explorer.exe"
| rex field=Caller_Process_Name "\\\(?&amp;lt;process_name_short&amp;gt;[^\\\]+$)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This doesn't:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count
| eval Caller_Process_Name = "C:\Windows\System32\explorer.exe"
| rex field=Caller_Process_Name "\\(?&amp;lt;process_name_short&amp;gt;[^\\]+$)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Anyway, let's focus on the actual problem and not mine's &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2016 17:38:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205200#M59650</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-01-04T17:38:39Z</dc:date>
    </item>
    <item>
      <title>Re: Regular Expression to Extract Values From a Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205201#M59651</link>
      <description>&lt;P&gt;Needed three slashes as the second was cancelling out the end square bracket.&lt;/P&gt;

&lt;P&gt;But IT WORKED!&lt;/P&gt;

&lt;P&gt;Here's the full command that worked:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=Caller_Process_Name "(?&amp;lt;process_name_short&amp;gt;[^\\\]+$)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This pulls out the program name part of the path and places it in a new field called process_name_short which I was able to run a stats command on to count up the different programs throwing audit fails.&lt;/P&gt;

&lt;P&gt;Thanks everyone!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 08:15:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-Values-From-a-Field/m-p/205201#M59651</guid>
      <dc:creator>Bytes</dc:creator>
      <dc:date>2020-09-29T08:15:47Z</dc:date>
    </item>
  </channel>
</rss>

