<?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: Help with rex for part of a file path in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Help-with-rex-for-part-of-a-file-path/m-p/488840#M136527</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval test="C:\WebLogs\sample.domain.com\W3SVC1\u_ex191121.log" 
| eval domain = mvindex(split(test,"\\"),2)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 22 Nov 2019 03:20:44 GMT</pubDate>
    <dc:creator>vnravikumar</dc:creator>
    <dc:date>2019-11-22T03:20:44Z</dc:date>
    <item>
      <title>Help with rex for part of a file path</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-rex-for-part-of-a-file-path/m-p/488835#M136522</link>
      <description>&lt;P&gt;Here is my path:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;C:\WebLogs\sample.domain.com\W3SVC1\u_ex191121.log
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would like to grab just the "sample.domain.com" part.&lt;/P&gt;

&lt;P&gt;Some of my files are on the E drive and the W3CSVC folders vary, but the sample.domain.com part is always the same format, although it may be sample1.domain2.com (changing, but always a valid url).&lt;/P&gt;

&lt;P&gt;It's my source field so I am hoping for something like rex field=source "super regex here".&lt;/P&gt;

&lt;P&gt;I really appreciate the help!&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2019 23:06:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-rex-for-part-of-a-file-path/m-p/488835#M136522</guid>
      <dc:creator>rileyken2</dc:creator>
      <dc:date>2019-11-21T23:06:48Z</dc:date>
    </item>
    <item>
      <title>Re: Help with rex for part of a file path</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-rex-for-part-of-a-file-path/m-p/488836#M136523</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex  field=path "^(?:[^\\]+\\){2}(?&amp;lt;domain&amp;gt;[^\\]+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Nov 2019 23:23:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-rex-for-part-of-a-file-path/m-p/488836#M136523</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-11-21T23:23:28Z</dc:date>
    </item>
    <item>
      <title>Re: Help with rex for part of a file path</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-rex-for-part-of-a-file-path/m-p/488837#M136524</link>
      <description>&lt;P&gt;I get an error, it doesn't seem to be missing a ] anywhere..?&lt;/P&gt;

&lt;P&gt;Error in 'rex' command: Encountered the following error while compiling the regex '^(?:[^]+){2}(?[^]+)': Regex: missing terminating ] for character class.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2019 00:26:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-rex-for-part-of-a-file-path/m-p/488837#M136524</guid>
      <dc:creator>rileyken2</dc:creator>
      <dc:date>2019-11-22T00:26:36Z</dc:date>
    </item>
    <item>
      <title>Re: Help with rex for part of a file path</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-rex-for-part-of-a-file-path/m-p/488838#M136525</link>
      <description>&lt;P&gt;Please use '\\' to escape '\'&lt;BR /&gt;
| rex field=path "^(?:[^\]+\){2}(?[^\]+)"&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2019 00:53:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-rex-for-part-of-a-file-path/m-p/488838#M136525</guid>
      <dc:creator>louismai</dc:creator>
      <dc:date>2019-11-22T00:53:29Z</dc:date>
    </item>
    <item>
      <title>Re: Help with rex for part of a file path</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-rex-for-part-of-a-file-path/m-p/488839#M136526</link>
      <description>&lt;P&gt;I added some more backslashes and it worked like a charm! Thanks Woodcock&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2019 00:58:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-rex-for-part-of-a-file-path/m-p/488839#M136526</guid>
      <dc:creator>rileyken2</dc:creator>
      <dc:date>2019-11-22T00:58:59Z</dc:date>
    </item>
    <item>
      <title>Re: Help with rex for part of a file path</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-rex-for-part-of-a-file-path/m-p/488840#M136527</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval test="C:\WebLogs\sample.domain.com\W3SVC1\u_ex191121.log" 
| eval domain = mvindex(split(test,"\\"),2)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Nov 2019 03:20:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-rex-for-part-of-a-file-path/m-p/488840#M136527</guid>
      <dc:creator>vnravikumar</dc:creator>
      <dc:date>2019-11-22T03:20:44Z</dc:date>
    </item>
    <item>
      <title>Re: Help with rex for part of a file path</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-rex-for-part-of-a-file-path/m-p/488841#M136528</link>
      <description>&lt;P&gt;I can not take the time or Regex seems to difficult to master for occasional problems, so I really appreciate the mvindex idea, I will definitely use this, thanks vnravikumar!&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2019 13:26:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-rex-for-part-of-a-file-path/m-p/488841#M136528</guid>
      <dc:creator>rileyken2</dc:creator>
      <dc:date>2019-11-22T13:26:20Z</dc:date>
    </item>
  </channel>
</rss>

