<?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: Regex search not working in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regex-search-not-working/m-p/257430#M77103</link>
    <description>&lt;P&gt;Hi dmittel,&lt;/P&gt;

&lt;P&gt;if the the events always have the same pattern like &lt;CODE&gt;\device\volume\name&lt;/CODE&gt; you can use this little regex:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; \\\w+\\\w+\\\w+
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;which will get &lt;CODE&gt;\Device\HarddiskVolume23\Test1&lt;/CODE&gt; from all provided examples.&lt;/P&gt;

&lt;P&gt;Hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
    <pubDate>Thu, 28 Jan 2016 21:59:50 GMT</pubDate>
    <dc:creator>MuS</dc:creator>
    <dc:date>2016-01-28T21:59:50Z</dc:date>
    <item>
      <title>Regex search not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-search-not-working/m-p/257429#M77102</link>
      <description>&lt;P&gt;So I have a couple of lines that I am trying to get info out of using regex and it's not going quite the way I was hoping.  Say in my events I have the lines below &lt;/P&gt;

&lt;P&gt;1.) &lt;CODE&gt;\Device\HarddiskVolume23\Test1&lt;/CODE&gt;&lt;BR /&gt;
2.) &lt;CODE&gt;\Device\HarddiskVolume23\Test1\Test&lt;/CODE&gt;&lt;BR /&gt;
3.) &lt;CODE&gt;\Device\HarddiskVolume23\Test1\Test\Test1&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;What I am looking to get is the results that would just be the root directories ( &lt;CODE&gt;\Device\HarddiskVolume23\Test1&lt;/CODE&gt; ).  So I'm trying to set up a regex that does just that, but I'm not having the best of luck.&lt;/P&gt;

&lt;P&gt;If I do the following, I will get the results 1 and 3 above.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;regex Object_Name="Test1$" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I was trying to set up the search so it would go:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;regex Object_Name="HarddiskVolume\d\\d\\Test1$"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That doesn't return any results.  Even if I used: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;regex Object_Name="HarddiskVolume23\\Test1$"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I do not get any results.&lt;/P&gt;

&lt;P&gt;I have multiple different paths to get this to search for, so that is why I would like to use as many regex variables as I can.&lt;/P&gt;

&lt;P&gt;So what can I do to get this to work properly?&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2016 21:37:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-search-not-working/m-p/257429#M77102</guid>
      <dc:creator>dmittel</dc:creator>
      <dc:date>2016-01-28T21:37:42Z</dc:date>
    </item>
    <item>
      <title>Re: Regex search not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-search-not-working/m-p/257430#M77103</link>
      <description>&lt;P&gt;Hi dmittel,&lt;/P&gt;

&lt;P&gt;if the the events always have the same pattern like &lt;CODE&gt;\device\volume\name&lt;/CODE&gt; you can use this little regex:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; \\\w+\\\w+\\\w+
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;which will get &lt;CODE&gt;\Device\HarddiskVolume23\Test1&lt;/CODE&gt; from all provided examples.&lt;/P&gt;

&lt;P&gt;Hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2016 21:59:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-search-not-working/m-p/257430#M77103</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2016-01-28T21:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: Regex search not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-search-not-working/m-p/257431#M77104</link>
      <description>&lt;P&gt;This works with your sample data.  Because SPL and the regex engine both use backslash as an escape character, you have to use 4 backslashes to match a backslash.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;regex Object_Name="\\\\\w+?\\\\\w+?\\\\\w+"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Jan 2016 22:02:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-search-not-working/m-p/257431#M77104</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-01-28T22:02:36Z</dc:date>
    </item>
    <item>
      <title>Re: Regex search not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-search-not-working/m-p/257432#M77105</link>
      <description>&lt;P&gt;The problem is the event isnt always &lt;CODE&gt;\device\volume\name&lt;/CODE&gt;.  There are other events logged that have other paths that I am not concerned about.&lt;/P&gt;

&lt;P&gt;When I try the &lt;CODE&gt;regex Object_Name="\\\\\w+?\\\\\w+?\\\\\w+"&lt;/CODE&gt; it returns all results&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2016 22:06:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-search-not-working/m-p/257432#M77105</guid>
      <dc:creator>dmittel</dc:creator>
      <dc:date>2016-01-28T22:06:20Z</dc:date>
    </item>
    <item>
      <title>Re: Regex search not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-search-not-working/m-p/257433#M77106</link>
      <description>&lt;P&gt;This works fine for me. (comes with run anywhere example with your sample data)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 | eval temp="\Device\HarddiskVolume23\Test1 \Device\HarddiskVolume23\Test1\Test \Device\HarddiskVolume23\Test1\Test\Test1" | makemv temp| table temp | mvexpand temp | regex temp="HarddiskVolume\d+\\\Test1$"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You're almost there, just missing additional backslash&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2016 22:23:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-search-not-working/m-p/257433#M77106</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-01-28T22:23:10Z</dc:date>
    </item>
    <item>
      <title>Re: Regex search not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-search-not-working/m-p/257434#M77107</link>
      <description>&lt;P&gt;This regex statement will match all three lines assuming each lines begins with a backslash.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;^(\\[^\\]+){3}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In SPL it would look like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| rex field=_raw "^(?&amp;lt;myfield&amp;gt;(\\[^\\]+){3})"
or 
...| rex field=_raw "^(?&amp;lt;myfield&amp;gt;(\\[^\\]+){3})" max_match=0 | 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Jan 2016 22:55:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-search-not-working/m-p/257434#M77107</guid>
      <dc:creator>bmacias84</dc:creator>
      <dc:date>2016-01-28T22:55:50Z</dc:date>
    </item>
  </channel>
</rss>

