<?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: What is the regular expression to extract substring from a string? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-regular-expression-to-extract-substring-from-a/m-p/302436#M91023</link>
    <description>&lt;P&gt;I am using this and its not working:&lt;/P&gt;

&lt;P&gt;source=*  "error"  host="*" | chart count by source | rex field=source "^([^\]+\)+(?[^\]+)\\"&lt;/P&gt;</description>
    <pubDate>Thu, 16 Feb 2017 20:41:58 GMT</pubDate>
    <dc:creator>rakeshcse2</dc:creator>
    <dc:date>2017-02-16T20:41:58Z</dc:date>
    <item>
      <title>What is the regular expression to extract substring from a string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-regular-expression-to-extract-substring-from-a/m-p/302432#M91019</link>
      <description>&lt;P&gt;My log source location is :  C:\logs\public\test\appname\test.log&lt;/P&gt;

&lt;P&gt;I need a regular expression to just extract "appname" from the source location in my search output and then display that as a new column name.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 20:01:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-regular-expression-to-extract-substring-from-a/m-p/302432#M91019</guid>
      <dc:creator>rakeshcse2</dc:creator>
      <dc:date>2017-02-16T20:01:08Z</dc:date>
    </item>
    <item>
      <title>Re: What is the regular expression to extract substring from a string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-regular-expression-to-extract-substring-from-a/m-p/302433#M91020</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Updated&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your current search giving field source which contains full file path
| rex field=source "^([^\\\\]+\\\\)+(?&amp;lt;AppName&amp;gt;[^\\\\]+)\\\\"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Runanywhere sample:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 | eval source="C:\logs\public\test\appname\test.log" | table source | rex field=source "^([^\\\\]+\\\\)+(?&amp;lt;AppName&amp;gt;[^\\\\]+)\\\\"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Feb 2017 20:28:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-regular-expression-to-extract-substring-from-a/m-p/302433#M91020</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-02-16T20:28:18Z</dc:date>
    </item>
    <item>
      <title>Re: What is the regular expression to extract substring from a string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-regular-expression-to-extract-substring-from-a/m-p/302434#M91021</link>
      <description>&lt;P&gt;Thank you, but the appname is not constant and it is different for different application.&lt;BR /&gt;
I need to extract any xyz appname from the source location.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 20:31:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-regular-expression-to-extract-substring-from-a/m-p/302434#M91021</guid>
      <dc:creator>rakeshcse2</dc:creator>
      <dc:date>2017-02-16T20:31:13Z</dc:date>
    </item>
    <item>
      <title>Re: What is the regular expression to extract substring from a string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-regular-expression-to-extract-substring-from-a/m-p/302435#M91022</link>
      <description>&lt;P&gt;It's capturing whatever string comes as the immediate parent to file name. The 2nd is just an example search to test it.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 20:34:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-regular-expression-to-extract-substring-from-a/m-p/302435#M91022</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-02-16T20:34:15Z</dc:date>
    </item>
    <item>
      <title>Re: What is the regular expression to extract substring from a string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-regular-expression-to-extract-substring-from-a/m-p/302436#M91023</link>
      <description>&lt;P&gt;I am using this and its not working:&lt;/P&gt;

&lt;P&gt;source=*  "error"  host="*" | chart count by source | rex field=source "^([^\]+\)+(?[^\]+)\\"&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 20:41:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-regular-expression-to-extract-substring-from-a/m-p/302436#M91023</guid>
      <dc:creator>rakeshcse2</dc:creator>
      <dc:date>2017-02-16T20:41:58Z</dc:date>
    </item>
    <item>
      <title>Re: What is the regular expression to extract substring from a string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-regular-expression-to-extract-substring-from-a/m-p/302437#M91024</link>
      <description>&lt;P&gt;Try with the updated string (needed one additional backslash, 4 at a time)&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 20:45:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-regular-expression-to-extract-substring-from-a/m-p/302437#M91024</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-02-16T20:45:55Z</dc:date>
    </item>
    <item>
      <title>Re: What is the regular expression to extract substring from a string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-regular-expression-to-extract-substring-from-a/m-p/302438#M91025</link>
      <description>&lt;P&gt;try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|stats c |eval _raw="C:\logs\public\test\appname\test.log"|rex field=_raw "\w+.\w+.\w+.(?&amp;lt;appname&amp;gt;\w+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Feb 2017 21:01:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-regular-expression-to-extract-substring-from-a/m-p/302438#M91025</guid>
      <dc:creator>mpreddy</dc:creator>
      <dc:date>2017-02-16T21:01:23Z</dc:date>
    </item>
    <item>
      <title>Re: What is the regular expression to extract substring from a string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-regular-expression-to-extract-substring-from-a/m-p/302439#M91026</link>
      <description>&lt;P&gt;Sorry, i deleted my last post , that was not clear.&lt;/P&gt;

&lt;P&gt;The thing is we just need to change teh regex to include one more / in the source path, that is :&lt;/P&gt;

&lt;P&gt;C:\logs\public\test\appname\abcd\test.log&lt;BR /&gt;
From the top i need to extract appname only.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 21:04:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-regular-expression-to-extract-substring-from-a/m-p/302439#M91026</guid>
      <dc:creator>rakeshcse2</dc:creator>
      <dc:date>2017-02-16T21:04:19Z</dc:date>
    </item>
    <item>
      <title>Re: What is the regular expression to extract substring from a string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-regular-expression-to-extract-substring-from-a/m-p/302440#M91027</link>
      <description>&lt;P&gt;You need to fix a position for the app name (earliest we assumed it was the last folder before the file name). So can we say it's always the 5th segment from start? If yes, then try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;....| rex field=source "^([^\\\\]+\\\\){4}(?&amp;lt;AppName&amp;gt;[^\\\\]+)\\\\"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Feb 2017 21:06:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-regular-expression-to-extract-substring-from-a/m-p/302440#M91027</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-02-16T21:06:45Z</dc:date>
    </item>
    <item>
      <title>Re: What is the regular expression to extract substring from a string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-regular-expression-to-extract-substring-from-a/m-p/302441#M91028</link>
      <description>&lt;P&gt;Thank you very much, that worked.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 22:23:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-regular-expression-to-extract-substring-from-a/m-p/302441#M91028</guid>
      <dc:creator>rakeshcse2</dc:creator>
      <dc:date>2017-02-16T22:23:20Z</dc:date>
    </item>
  </channel>
</rss>

