<?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: How do I split a string which contains a path so I'm only getting the first two directories? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-split-a-string-which-contains-a-path-so-I-m-only/m-p/162520#M46085</link>
    <description>&lt;P&gt;That regex doesn't compile.&lt;/P&gt;

&lt;P&gt;If you meant to use a non-capturing group it should be &lt;CODE&gt;(?:&lt;/CODE&gt;, not &lt;CODE&gt;(?;&lt;/CODE&gt;.&lt;/P&gt;</description>
    <pubDate>Sun, 21 Jun 2015 08:48:48 GMT</pubDate>
    <dc:creator>martin_mueller</dc:creator>
    <dc:date>2015-06-21T08:48:48Z</dc:date>
    <item>
      <title>How do I split a string which contains a path so I'm only getting the first two directories?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-split-a-string-which-contains-a-path-so-I-m-only/m-p/162518#M46083</link>
      <description>&lt;P&gt;I have several thousand events with a path such as &lt;CODE&gt;d:\RNREDINFFTP01-AVREDINFWFS01\ebtest1\foo\bar\filename2.txt&lt;/CODE&gt;.  The folder name is not static - I'm using a fschange monitor to pull the events so the root directory &lt;CODE&gt;RNREDINFFTP01-AVREDINFWFS01&lt;/CODE&gt; and the tertiary directories are not static.&lt;/P&gt;

&lt;P&gt;I want to show the size of the files based on the first or second directory, depending on the users need for detail.  For instance.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;d:\RNREDINFFTP01-AVREDINFWFS01   100 files 100mb
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OR&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;d:\RNREDINFFTP01-AVREDINFWFS01\ebtest1 50 files 50mb
d:\RNREDINFFTP01-AVREDINFWFS01\ebtest2 40 files 40mb
d:\RNREDINFFTP01-AVREDINFWFS01\ebtest3 10 files 10mb
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I doubt I'll ever go past the 2nd directory.  I've tried using rex and can't seem to get the groups right.  If I was using vbscript or powershell I'd simply call split based on &lt;CODE&gt;\&lt;/CODE&gt; and then group by the first or the first+second directories.  What am I missing?? ...and... what is the best way to tackle this?&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jun 2015 11:10:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-split-a-string-which-contains-a-path-so-I-m-only/m-p/162518#M46083</guid>
      <dc:creator>DamageSplunk</dc:creator>
      <dc:date>2015-06-20T11:10:15Z</dc:date>
    </item>
    <item>
      <title>Re: How do I split a string which contains a path so I'm only getting the first two directories?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-split-a-string-which-contains-a-path-so-I-m-only/m-p/162519#M46084</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... rex field=source "(?&amp;lt;PathPrefix&amp;gt;(?:[^\\\]+\\\){2})"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 20 Jun 2015 11:45:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-split-a-string-which-contains-a-path-so-I-m-only/m-p/162519#M46084</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-06-20T11:45:19Z</dc:date>
    </item>
    <item>
      <title>Re: How do I split a string which contains a path so I'm only getting the first two directories?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-split-a-string-which-contains-a-path-so-I-m-only/m-p/162520#M46085</link>
      <description>&lt;P&gt;That regex doesn't compile.&lt;/P&gt;

&lt;P&gt;If you meant to use a non-capturing group it should be &lt;CODE&gt;(?:&lt;/CODE&gt;, not &lt;CODE&gt;(?;&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Sun, 21 Jun 2015 08:48:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-split-a-string-which-contains-a-path-so-I-m-only/m-p/162520#M46085</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2015-06-21T08:48:48Z</dc:date>
    </item>
    <item>
      <title>Re: How do I split a string which contains a path so I'm only getting the first two directories?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-split-a-string-which-contains-a-path-so-I-m-only/m-p/162521#M46086</link>
      <description>&lt;P&gt;Yes, thank you for catching the typo (stupid dumb-phone keyboard).  It is fixed now.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jun 2015 16:13:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-split-a-string-which-contains-a-path-so-I-m-only/m-p/162521#M46086</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-06-22T16:13:39Z</dc:date>
    </item>
    <item>
      <title>Re: How do I split a string which contains a path so I'm only getting the first two directories?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-split-a-string-which-contains-a-path-so-I-m-only/m-p/162522#M46087</link>
      <description>&lt;P&gt;Thanks but I'm getting a different error now, Error in 'rex' command: Encountered the following error while compiling the regex '(?(?:[^]+){2})': Regex: missing terminating ] for character class .&lt;/P&gt;

&lt;P&gt;I don't see any issues, there's matching Parens and Braces.  Any ideas?&lt;/P&gt;

&lt;P&gt;Thanks - Eric&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jun 2015 19:16:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-split-a-string-which-contains-a-path-so-I-m-only/m-p/162522#M46087</guid>
      <dc:creator>DamageSplunk</dc:creator>
      <dc:date>2015-06-22T19:16:36Z</dc:date>
    </item>
    <item>
      <title>Re: How do I split a string which contains a path so I'm only getting the first two directories?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-split-a-string-which-contains-a-path-so-I-m-only/m-p/162523#M46088</link>
      <description>&lt;P&gt;OK, it turns out you need an additional escape character like this (fixed in original answer, too):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... rex field=source "(?&amp;lt;PathPrefix&amp;gt;(?:[^\\\]+\\\){2})"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Jun 2015 19:32:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-split-a-string-which-contains-a-path-so-I-m-only/m-p/162523#M46088</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-06-22T19:32:01Z</dc:date>
    </item>
    <item>
      <title>Re: How do I split a string which contains a path so I'm only getting the first two directories?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-split-a-string-which-contains-a-path-so-I-m-only/m-p/162524#M46089</link>
      <description>&lt;P&gt;That did it!  Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jun 2015 19:36:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-split-a-string-which-contains-a-path-so-I-m-only/m-p/162524#M46089</guid>
      <dc:creator>DamageSplunk</dc:creator>
      <dc:date>2015-06-22T19:36:29Z</dc:date>
    </item>
    <item>
      <title>Re: How do I split a string which contains a path so I'm only getting the first two directories?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-split-a-string-which-contains-a-path-so-I-m-only/m-p/589357#M205228</link>
      <description>&lt;P&gt;I'm trying to adapt this for a UNIX path, and I can't tell why it's not working.&lt;/P&gt;&lt;P&gt;I have is&amp;nbsp;&lt;/P&gt;&lt;P&gt;rex field=uri "(?&amp;lt;PathPrefix&amp;gt;(?:[^/]+/){2})"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2022 15:11:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-split-a-string-which-contains-a-path-so-I-m-only/m-p/589357#M205228</guid>
      <dc:creator>fdinkler</dc:creator>
      <dc:date>2022-03-16T15:11:39Z</dc:date>
    </item>
  </channel>
</rss>

