<?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 to write the regex to extract this string between the 3rd and 6th underscores in my sample data? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-the-regex-to-extract-this-string-between-the-3rd/m-p/205070#M59590</link>
    <description>&lt;P&gt;the values at the end "1190FA52.log" is not constant (not always 13 at end)&lt;/P&gt;</description>
    <pubDate>Thu, 09 Jun 2016 07:45:32 GMT</pubDate>
    <dc:creator>deenadp</dc:creator>
    <dc:date>2016-06-09T07:45:32Z</dc:date>
    <item>
      <title>How to write the regex to extract this string between the 3rd and 6th underscores in my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-the-regex-to-extract-this-string-between-the-3rd/m-p/205069#M59589</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I would like to extract the strings between multiple delimiters as below.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;INPUT : src=`D:\GENEOS Program Files\App\FILE_DC_BP_JOBS_APACHE_DISPLAY_1190FA52.log`
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;From the above I need to extract only &lt;CODE&gt;JOBS_APACHE_DISPLAY&lt;/CODE&gt;. &lt;/P&gt;

&lt;P&gt;Can you please help? I have tried with multiple regex options, but it also fetches additional strings.&lt;/P&gt;

&lt;P&gt;Below is my attempt:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval log=replace(src,"([^\\\]+\\\)","")| eval Name=substr(log,1,len(log)-13)| eval Name=substr(Name,12,len(log))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;req: need to display the strings between 3rd and 6th &lt;CODE&gt;_&lt;/CODE&gt; from &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;gt; FILE_DC_BP_JOBS_APACHE_DISPLAY_1190FA52.log
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Jun 2016 07:34:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-the-regex-to-extract-this-string-between-the-3rd/m-p/205069#M59589</guid>
      <dc:creator>deenadp</dc:creator>
      <dc:date>2016-06-09T07:34:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to write the regex to extract this string between the 3rd and 6th underscores in my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-the-regex-to-extract-this-string-between-the-3rd/m-p/205070#M59590</link>
      <description>&lt;P&gt;the values at the end "1190FA52.log" is not constant (not always 13 at end)&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jun 2016 07:45:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-the-regex-to-extract-this-string-between-the-3rd/m-p/205070#M59590</guid>
      <dc:creator>deenadp</dc:creator>
      <dc:date>2016-06-09T07:45:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to write the regex to extract this string between the 3rd and 6th underscores in my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-the-regex-to-extract-this-string-between-the-3rd/m-p/205071#M59591</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;.... |  eval src=split(src, "_") | eval log=mvindex(src, 3)."_".mvindex(src, 4)."_".mvindex(src, 5)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Jun 2016 11:16:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-the-regex-to-extract-this-string-between-the-3rd/m-p/205071#M59591</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-06-09T11:16:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to write the regex to extract this string between the 3rd and 6th underscores in my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-the-regex-to-extract-this-string-between-the-3rd/m-p/205072#M59592</link>
      <description>&lt;P&gt;Since your question mentioned regex, here's a solution using rex&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field=src "\w+_\w+_\w+_(?&amp;lt;log&amp;gt;\w+_\w+_\w+)_" | ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Jun 2016 12:33:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-the-regex-to-extract-this-string-between-the-3rd/m-p/205072#M59592</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-06-09T12:33:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to write the regex to extract this string between the 3rd and 6th underscores in my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-the-regex-to-extract-this-string-between-the-3rd/m-p/205073#M59593</link>
      <description>&lt;P&gt;This should work as well as better regex with lookahead lookbehind.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jun 2016 13:54:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-the-regex-to-extract-this-string-between-the-3rd/m-p/205073#M59593</guid>
      <dc:creator>axl88</dc:creator>
      <dc:date>2016-06-09T13:54:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to write the regex to extract this string between the 3rd and 6th underscores in my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-the-regex-to-extract-this-string-between-the-3rd/m-p/205074#M59594</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field=src "(?:[^_]+_){3}(?&amp;lt;capture&amp;gt;[^_]+_[^_]+_[^_]+)_"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Jun 2016 17:34:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-the-regex-to-extract-this-string-between-the-3rd/m-p/205074#M59594</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-06-13T17:34:23Z</dc:date>
    </item>
  </channel>
</rss>

