<?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 extract URI using regex? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-extract-URI-using-regex/m-p/307074#M92090</link>
    <description>&lt;P&gt;try this!&lt;BR /&gt;
If you want to capture say &lt;CODE&gt;benefits&lt;/CODE&gt; and &lt;CODE&gt;excluded&lt;/CODE&gt; in one event then try this!&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | rex field=URI max_match=0 "(MED|\d{2,})\/(?P&amp;lt;sec&amp;gt;\w+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OR &lt;BR /&gt;
if you want in three different field then use this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=URI "(?&amp;lt;first&amp;gt;^\/[^\/]+\/[^\/]+\/[^\/]+)\/[^\/]+\/(?&amp;lt;second&amp;gt;\w+)\/.*\/(?&amp;lt;Third&amp;gt;\w+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 16 Jan 2018 07:42:27 GMT</pubDate>
    <dc:creator>mayurr98</dc:creator>
    <dc:date>2018-01-16T07:42:27Z</dc:date>
    <item>
      <title>How extract URI using regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-extract-URI-using-regex/m-p/307070#M92086</link>
      <description>&lt;P&gt;I need to extract fields which mentioned in yellow?&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/4151i149AA5260BB7D86F/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2018 05:51:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-extract-URI-using-regex/m-p/307070#M92086</guid>
      <dc:creator>karthi2809</dc:creator>
      <dc:date>2018-01-16T05:51:21Z</dc:date>
    </item>
    <item>
      <title>Re: How extract URI using regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-extract-URI-using-regex/m-p/307071#M92087</link>
      <description>&lt;P&gt;hey &lt;/P&gt;

&lt;P&gt;you can try this run anywhere search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval URI="/v1/cp/members/257425525/benefits/999F-20180101-20181231-MED/excluded" | rex field=URI "(?&amp;lt;first&amp;gt;^\/[^\/]+\/[^\/]+\/[^\/]+)\/[^\/]+\/(?&amp;lt;second&amp;gt;\w+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In your environment, you should write&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;base_search&amp;gt; | rex field=URI "(?&amp;lt;first&amp;gt;^\/[^\/]+\/[^\/]+\/[^\/]+)\/[^\/]+\/(?&amp;lt;second&amp;gt;\w+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;let me know if this helps!&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2018 06:11:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-extract-URI-using-regex/m-p/307071#M92087</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2018-01-16T06:11:34Z</dc:date>
    </item>
    <item>
      <title>Re: How extract URI using regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-extract-URI-using-regex/m-p/307072#M92088</link>
      <description>&lt;P&gt;You can try the following...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?&amp;lt;capture1&amp;gt;\/(\w+\/){3})\d+\/(?&amp;lt;capture2&amp;gt;\w+)\/.*\/(?&amp;lt;capture3&amp;gt;\w+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In SPL... &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval URI="/v1/cp/members/257425525/benefits/999F-20180101-20181231-MED/excluded" 
| rex field=URI "(?&amp;lt;capture1&amp;gt;\/(\w+\/){3})\d+\/(?&amp;lt;capture2&amp;gt;\w+)\/.*\/(?&amp;lt;capture3&amp;gt;\w+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will work for up to the third iteration. If you need to keep capturing, you can keep adding to that regex...&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2018 06:17:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-extract-URI-using-regex/m-p/307072#M92088</guid>
      <dc:creator>esix_splunk</dc:creator>
      <dc:date>2018-01-16T06:17:44Z</dc:date>
    </item>
    <item>
      <title>Re: How extract URI using regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-extract-URI-using-regex/m-p/307073#M92089</link>
      <description>&lt;P&gt;Hi mayurr&lt;/P&gt;

&lt;P&gt;Thanks for you valuable answer but i send sample URI .there is lot of URI like this how can we extract using mode=sed&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2018 07:12:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-extract-URI-using-regex/m-p/307073#M92089</guid>
      <dc:creator>karthi2809</dc:creator>
      <dc:date>2018-01-16T07:12:42Z</dc:date>
    </item>
    <item>
      <title>Re: How extract URI using regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-extract-URI-using-regex/m-p/307074#M92090</link>
      <description>&lt;P&gt;try this!&lt;BR /&gt;
If you want to capture say &lt;CODE&gt;benefits&lt;/CODE&gt; and &lt;CODE&gt;excluded&lt;/CODE&gt; in one event then try this!&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | rex field=URI max_match=0 "(MED|\d{2,})\/(?P&amp;lt;sec&amp;gt;\w+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OR &lt;BR /&gt;
if you want in three different field then use this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=URI "(?&amp;lt;first&amp;gt;^\/[^\/]+\/[^\/]+\/[^\/]+)\/[^\/]+\/(?&amp;lt;second&amp;gt;\w+)\/.*\/(?&amp;lt;Third&amp;gt;\w+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Jan 2018 07:42:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-extract-URI-using-regex/m-p/307074#M92090</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2018-01-16T07:42:27Z</dc:date>
    </item>
  </channel>
</rss>

