<?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 How can I improve my regular expression to extract a field located inside a URL? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-improve-my-regular-expression-to-extract-a-field/m-p/244938#M72959</link>
    <description>&lt;P&gt;Hey i have the following logs:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;INCOMING REQUEST:
URL:  /pop/v1/enviro/2ee999b4-d97ba81bdefd/updatesearching/
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;i need to extract  the numbers after &lt;CODE&gt;enviro/&lt;/CODE&gt; and before &lt;CODE&gt;/updatesearching&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;i created following regular expression: &lt;CODE&gt;REX "URL:\s\/\w+\/\w+\/\enviro/(?.*)/updatesearching/&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;but i'm not getting it. how can i improve the regular expression or how can i extract that number?&lt;/P&gt;</description>
    <pubDate>Fri, 20 Jan 2017 15:52:35 GMT</pubDate>
    <dc:creator>guillecasco</dc:creator>
    <dc:date>2017-01-20T15:52:35Z</dc:date>
    <item>
      <title>How can I improve my regular expression to extract a field located inside a URL?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-improve-my-regular-expression-to-extract-a-field/m-p/244938#M72959</link>
      <description>&lt;P&gt;Hey i have the following logs:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;INCOMING REQUEST:
URL:  /pop/v1/enviro/2ee999b4-d97ba81bdefd/updatesearching/
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;i need to extract  the numbers after &lt;CODE&gt;enviro/&lt;/CODE&gt; and before &lt;CODE&gt;/updatesearching&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;i created following regular expression: &lt;CODE&gt;REX "URL:\s\/\w+\/\w+\/\enviro/(?.*)/updatesearching/&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;but i'm not getting it. how can i improve the regular expression or how can i extract that number?&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2017 15:52:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-improve-my-regular-expression-to-extract-a-field/m-p/244938#M72959</guid>
      <dc:creator>guillecasco</dc:creator>
      <dc:date>2017-01-20T15:52:35Z</dc:date>
    </item>
    <item>
      <title>Re: How can I improve my regular expression to extract a field located inside a URL?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-improve-my-regular-expression-to-extract-a-field/m-p/244939#M72960</link>
      <description>&lt;P&gt;Can you please try this and see if it works for you:&lt;/P&gt;

&lt;P&gt;If it's always between &lt;CODE&gt;enviro&lt;/CODE&gt; and &lt;CODE&gt;updatesearching&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your query to return events
|rex field=_raw "enviro\/(?&amp;lt;capturedNum&amp;gt;[^\/]+)\/updatesearching"
| table capturedNum
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If the numbers of interest come always after &lt;CODE&gt;enviro&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your query to return events
|rex field=_raw "\/enviro\/(?&amp;lt;capturedNum&amp;gt;[^\/]+)\/"
| table capturedNum
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If it's always the fourth element then try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your query to return events
|rex field=_raw "URL:\s*\/([^\s\/]+\/){3}(?&amp;lt;capturedNum&amp;gt;[^\/]+)\/"
| table capturedNum
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Jan 2017 16:04:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-improve-my-regular-expression-to-extract-a-field/m-p/244939#M72960</guid>
      <dc:creator>gokadroid</dc:creator>
      <dc:date>2017-01-20T16:04:32Z</dc:date>
    </item>
    <item>
      <title>Re: How can I improve my regular expression to extract a field located inside a URL?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-improve-my-regular-expression-to-extract-a-field/m-p/244940#M72961</link>
      <description>&lt;P&gt;it worked! |rex field=_raw "enviro\/(?[^\/]+)\/updatesearching"   thanks dude&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2017 17:58:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-improve-my-regular-expression-to-extract-a-field/m-p/244940#M72961</guid>
      <dc:creator>guillecasco</dc:creator>
      <dc:date>2017-01-20T17:58:10Z</dc:date>
    </item>
    <item>
      <title>Re: How can I improve my regular expression to extract a field located inside a URL?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-improve-my-regular-expression-to-extract-a-field/m-p/244941#M72962</link>
      <description>&lt;P&gt;what is the field=_raw does exactly. I didnt put there anything&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2017 18:02:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-improve-my-regular-expression-to-extract-a-field/m-p/244941#M72962</guid>
      <dc:creator>guillecasco</dc:creator>
      <dc:date>2017-01-20T18:02:49Z</dc:date>
    </item>
  </channel>
</rss>

