<?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 to write the regex in my search to extract first part of uri path in access logs? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-the-regex-in-my-search-to-extract-first-part-of-uri/m-p/190108#M54743</link>
    <description>&lt;P&gt;Below is the string I need to extract ROM_RAMESH from and similarly there are multiple client info so I need a regular expression and I am very new to that.&lt;BR /&gt;
I used the extract field but can't get what I need ...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;21.432.632.53 - - [14/Jan/2015:13:23:57 -0500] "GET /ROM_RAMESH/images/bg.gif HTTP/1.1" 200 64 - 38E8352722F7ADE88844A3B026752BCC.bgitcostumen1 - - &lt;A href="https://cbsplake.boysdtom.com/ROM_RAMESH/BrandHistory.do" target="test_blank"&gt;https://cbsplake.boysdtom.com/ROM_RAMESH/BrandHistory.do&lt;/A&gt; -
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;When I use this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index="cc_web" sourcetype= * | rex field=_raw "(?i)^(?:[^\-]*\-){6}\s+(?P.+?)\w+\.\w+\s+" | top limit=100 Clients
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I get only this as a result &lt;BR /&gt;
&lt;A href="https://cbsplake.boysdtom.com/ROM_RAMESH/"&gt;https://cbsplake.boysdtom.com/ROM_RAMESH/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I need &lt;BR /&gt;
ROM_RAMESH&lt;/P&gt;</description>
    <pubDate>Thu, 22 Jan 2015 19:38:56 GMT</pubDate>
    <dc:creator>puneetkharband1</dc:creator>
    <dc:date>2015-01-22T19:38:56Z</dc:date>
    <item>
      <title>How to write the regex in my search to extract first part of uri path in access logs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-the-regex-in-my-search-to-extract-first-part-of-uri/m-p/190108#M54743</link>
      <description>&lt;P&gt;Below is the string I need to extract ROM_RAMESH from and similarly there are multiple client info so I need a regular expression and I am very new to that.&lt;BR /&gt;
I used the extract field but can't get what I need ...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;21.432.632.53 - - [14/Jan/2015:13:23:57 -0500] "GET /ROM_RAMESH/images/bg.gif HTTP/1.1" 200 64 - 38E8352722F7ADE88844A3B026752BCC.bgitcostumen1 - - &lt;A href="https://cbsplake.boysdtom.com/ROM_RAMESH/BrandHistory.do" target="test_blank"&gt;https://cbsplake.boysdtom.com/ROM_RAMESH/BrandHistory.do&lt;/A&gt; -
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;When I use this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index="cc_web" sourcetype= * | rex field=_raw "(?i)^(?:[^\-]*\-){6}\s+(?P.+?)\w+\.\w+\s+" | top limit=100 Clients
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I get only this as a result &lt;BR /&gt;
&lt;A href="https://cbsplake.boysdtom.com/ROM_RAMESH/"&gt;https://cbsplake.boysdtom.com/ROM_RAMESH/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I need &lt;BR /&gt;
ROM_RAMESH&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jan 2015 19:38:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-the-regex-in-my-search-to-extract-first-part-of-uri/m-p/190108#M54743</guid>
      <dc:creator>puneetkharband1</dc:creator>
      <dc:date>2015-01-22T19:38:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to write the regex in my search to extract first part of uri path in access logs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-the-regex-in-my-search-to-extract-first-part-of-uri/m-p/190109#M54744</link>
      <description>&lt;P&gt;If your input is having the built-in httpd access transforms applied, you should have access to the uri_path field and this should work and give you a field called field1:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[your search]| rex field=uri_path "^/(?&amp;lt;field1&amp;gt;[^/]*)/"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you are not using the access log transforms with this sourcetype then the following should also work for GET and POST requests:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; [your search] | rex field=_raw "(GET|POST)\s/(?&amp;lt;field1&amp;gt;[^/]*)/"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Jan 2015 20:03:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-the-regex-in-my-search-to-extract-first-part-of-uri/m-p/190109#M54744</guid>
      <dc:creator>chanfoli</dc:creator>
      <dc:date>2015-01-22T20:03:29Z</dc:date>
    </item>
  </channel>
</rss>

