<?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: regex extract capturing group value in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/regex-extract-capturing-group-value/m-p/24446#M4512</link>
    <description>&lt;P&gt;To me the solution is not clear. To state again , i want to match my URL against different values and if none of the value match then i want to extract a part of URL.&lt;/P&gt;</description>
    <pubDate>Mon, 05 Aug 2013 10:31:43 GMT</pubDate>
    <dc:creator>splunkuser2013</dc:creator>
    <dc:date>2013-08-05T10:31:43Z</dc:date>
    <item>
      <title>regex extract capturing group value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/regex-extract-capturing-group-value/m-p/24444#M4510</link>
      <description>&lt;P&gt;I would like to use function case and regex together and extract the value of capturing group in one field&lt;BR /&gt;
e.g. http_request field value is : &lt;CODE&gt;abcd.com/getdata?type=numberEnabled&lt;/CODE&gt;  or &lt;CODE&gt;abcd.com/showdata?type=numberEnabled&lt;/CODE&gt; &lt;BR /&gt;
Would like to do something like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; eval mode=case(regex(http_request,".*(getdata|showdata).*numberEnabled",$1.Enabled, true(), "other")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and it should return&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;getdata.Enabled
showdata.Enbaled
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Aug 2013 08:55:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/regex-extract-capturing-group-value/m-p/24444#M4510</guid>
      <dc:creator>splunkuser2013</dc:creator>
      <dc:date>2013-08-05T08:55:39Z</dc:date>
    </item>
    <item>
      <title>Re: regex extract capturing group value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/regex-extract-capturing-group-value/m-p/24445#M4511</link>
      <description>&lt;P&gt;I think it's better to state what problem you're trying to solve rather than saying how explicitly you would like to solve it. Your proposed solution is not how it works in Splunk. You'd first extract the &lt;CODE&gt;getdata&lt;/CODE&gt; or &lt;CODE&gt;showdata&lt;/CODE&gt; string, then do an &lt;CODE&gt;eval&lt;/CODE&gt; where you check if you got a value for that field. Something like this.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field=http_request ".*(?&amp;lt;endpoint&amp;gt;getdata|showdata).*numberEnabled" | eval mode=if(isnotnull(endpoint), endpoint . "Enabled", "other")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Aug 2013 10:05:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/regex-extract-capturing-group-value/m-p/24445#M4511</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2013-08-05T10:05:22Z</dc:date>
    </item>
    <item>
      <title>Re: regex extract capturing group value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/regex-extract-capturing-group-value/m-p/24446#M4512</link>
      <description>&lt;P&gt;To me the solution is not clear. To state again , i want to match my URL against different values and if none of the value match then i want to extract a part of URL.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Aug 2013 10:31:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/regex-extract-capturing-group-value/m-p/24446#M4512</guid>
      <dc:creator>splunkuser2013</dc:creator>
      <dc:date>2013-08-05T10:31:43Z</dc:date>
    </item>
    <item>
      <title>Re: regex extract capturing group value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/regex-extract-capturing-group-value/m-p/24447#M4513</link>
      <description>&lt;P&gt;OK? In your example you had a case function ending with the string "other" as fallback, so that's what I've done in my proposed solution as well. What part of the URL would you want to extract as a fallback option?&lt;/P&gt;</description>
      <pubDate>Mon, 05 Aug 2013 10:58:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/regex-extract-capturing-group-value/m-p/24447#M4513</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2013-08-05T10:58:15Z</dc:date>
    </item>
  </channel>
</rss>

