<?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 to extract a number from string in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-a-number-from-string/m-p/265186#M79720</link>
    <description>&lt;P&gt;@ramark  This thread is more than three years old and has an accepted answer so it's unlikely anyone will see your response.  If you are having a similar problem, please post a new question describing it and how this answer did not solve it.&lt;/P&gt;</description>
    <pubDate>Fri, 08 Mar 2019 16:38:11 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2019-03-08T16:38:11Z</dc:date>
    <item>
      <title>Regex to extract a number from string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-a-number-from-string/m-p/265179#M79713</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I am trying (rather unsuccessfully) to extract a number of varying length form a sting. The constants are 0s and us with the string in question being 0s/XXXXXus (with X being the numbers I am trying to extract - the number length varies).&lt;/P&gt;

&lt;P&gt;I have tried some examples but none do what i am after (most likely due to the fact that I am not sure how best to modify them).&lt;/P&gt;

&lt;P&gt;My expression is &lt;CODE&gt;"0s/(?\d+)us$"&lt;/CODE&gt; but as mentioned above it is not working.&lt;/P&gt;

&lt;P&gt;Help !!!&lt;/P&gt;

&lt;P&gt;Much thanks in adavance for any help or pointers.&lt;/P&gt;

&lt;P&gt;Cheers,&lt;/P&gt;

&lt;P&gt;Alastair&lt;/P&gt;</description>
      <pubDate>Tue, 02 Feb 2016 23:42:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-a-number-from-string/m-p/265179#M79713</guid>
      <dc:creator>ahogbin</dc:creator>
      <dc:date>2016-02-02T23:42:28Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to extract a number from string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-a-number-from-string/m-p/265180#M79714</link>
      <description>&lt;P&gt;Without sample data, it would be tough to provide most correct option but give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | rex field=_raw "0s\/(?&amp;lt;YourNumber&amp;gt;\d+)us$"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Feb 2016 23:47:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-a-number-from-string/m-p/265180#M79714</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-02-02T23:47:24Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to extract a number from string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-a-number-from-string/m-p/265181#M79715</link>
      <description>&lt;P&gt;If you have difficulty, try removing the trailing &lt;CODE&gt;$&lt;/CODE&gt; sign.  In that context it means "the end of the entire line" and as somesoni2 mentioned without sample data it's hard to confirm if it's the end of the string or not.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | rex field=_raw "0s\/(?&amp;lt;YourNumber&amp;gt;\d+)us"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 Feb 2016 00:22:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-a-number-from-string/m-p/265181#M79715</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2016-02-03T00:22:09Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to extract a number from string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-a-number-from-string/m-p/265182#M79716</link>
      <description>&lt;P&gt;Umm... still no joy.&lt;/P&gt;

&lt;P&gt;The sample data is&lt;BR /&gt;
10.93.10.26 - - [03/Feb/2016:11:02:41 +1100] "POST /web/uw-wbc/motor-quote?p_auth=9TDBHxxK&amp;amp;p_p_id=InternetMotorQuotePortlet_WAR_UnderwritingManagementView&amp;amp;p_p_lifecycle=1&amp;amp;p_p_state=normal&amp;amp;p_p_mode=view&amp;amp;p_p_col_id=column-1&amp;amp;p_p_col_count=2&amp;amp;p_p_col_pos=1&amp;amp;&lt;EM&gt;InternetMotorQuotePortlet_WAR_UnderwritingManagementView&lt;/EM&gt;&lt;EM&gt;facesViewIdRender=%2FWEB-INF%2Fpages%2Fquote%2Fmotor-internet%2FvehicleDetailsInternet.xhtml HTTP/1.1" 200 98343 "&lt;A href="https://www.einsure.com.au/safire/web/uw-wbc/motor-quote?p_auth=9TDBHxxK&amp;amp;p_p_id=InternetMotorQuotePortlet_WAR_UnderwritingManagementView&amp;amp;p_p_lifecycle=1&amp;amp;p_p_state=normal&amp;amp;p_p_mode=view&amp;amp;p_p_col_id=column-1&amp;amp;p_p_col_count=2&amp;amp;p_p_col_pos=1&amp;amp;_InternetMotorQuotePortlet_WAR_UnderwritingManagementView" target="_blank"&gt;https://www.einsure.com.au/safire/web/uw-wbc/motor-quote?p_auth=9TDBHxxK&amp;amp;p_p_id=InternetMotorQuotePortlet_WAR_UnderwritingManagementView&amp;amp;p_p_lifecycle=1&amp;amp;p_p_state=normal&amp;amp;p_p_mode=view&amp;amp;p_p_col_id=column-1&amp;amp;p_p_col_count=2&amp;amp;p_p_col_pos=1&amp;amp;_InternetMotorQuotePortlet_WAR_UnderwritingManagementView&lt;/A&gt;&lt;/EM&gt;_facesViewIdRender=%2FWEB-INF%2Fpages%2Fquote%2Fmotor-internet%2FyourDetails.xhtml" "Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko" - 98343 bytes 1s/1754987us Unauthenticated 00009CLAaSHjoHtKqKTPFURE3ob:18mta0ukm&lt;/P&gt;

&lt;P&gt;and the attempted extraction appears towards the end of the sample (after the word bytes). I have amended to include the varying number before 's'&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex field=_raw "\ds\/(?&amp;lt;RESP&amp;gt;\d+)us$"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thank you for the help so far&lt;/P&gt;

&lt;P&gt;Cheers,&lt;/P&gt;

&lt;P&gt;Alastair&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 08:39:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-a-number-from-string/m-p/265182#M79716</guid>
      <dc:creator>ahogbin</dc:creator>
      <dc:date>2020-09-29T08:39:05Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to extract a number from string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-a-number-from-string/m-p/265183#M79717</link>
      <description>&lt;P&gt;Perfect... as you suggested I just needed to remove the trailing $ as the data did not occur at the end of the line.&lt;/P&gt;

&lt;P&gt;Please ignore the post below&lt;/P&gt;

&lt;P&gt;Thank you so much&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2016 00:26:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-a-number-from-string/m-p/265183#M79717</guid>
      <dc:creator>ahogbin</dc:creator>
      <dc:date>2016-02-03T00:26:17Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to extract a number from string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-a-number-from-string/m-p/265184#M79718</link>
      <description>&lt;P&gt;I've found regex101.com to be very helpful debugging regexes, and there's a good bit of online help available on the page if you need a refresher on regex syntax.  For learning regexes and advanced topics, check out &lt;A href="http://www.regular-expressions.info"&gt;www.regular-expressions.info&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2016 14:58:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-a-number-from-string/m-p/265184#M79718</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2016-02-03T14:58:07Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to extract a number from string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-a-number-from-string/m-p/265185#M79719</link>
      <description>&lt;P&gt;I want extract 301.   Log "GET / HTTP/1.1" 301 248.&lt;BR /&gt;
Thanks,I want to extract   301    in "GET / HTTP/1.1" 301 248. Any help.&lt;BR /&gt;
Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 16:29:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-a-number-from-string/m-p/265185#M79719</guid>
      <dc:creator>ramark</dc:creator>
      <dc:date>2019-03-08T16:29:04Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to extract a number from string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-a-number-from-string/m-p/265186#M79720</link>
      <description>&lt;P&gt;@ramark  This thread is more than three years old and has an accepted answer so it's unlikely anyone will see your response.  If you are having a similar problem, please post a new question describing it and how this answer did not solve it.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 16:38:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-a-number-from-string/m-p/265186#M79720</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-03-08T16:38:11Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to extract a number from string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-a-number-from-string/m-p/265187#M79721</link>
      <description>&lt;P&gt;"GET \/ HTTP\/\d.\d" (?\d{3})&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 16:41:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-a-number-from-string/m-p/265187#M79721</guid>
      <dc:creator>macadminrohit</dc:creator>
      <dc:date>2019-03-08T16:41:23Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to extract a number from string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-a-number-from-string/m-p/265188#M79722</link>
      <description>&lt;P&gt;|rex field=_raw "GET \/ HTTP\/\d.\d" (?\d{3})&lt;BR /&gt;&lt;BR /&gt;
Error in 'rex' command: The regex 'GET \/ HTTP\/\d.\d' does not extract anything. It should specify at least one named group. Format: (?...).&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 17:16:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-a-number-from-string/m-p/265188#M79722</guid>
      <dc:creator>ramark</dc:creator>
      <dc:date>2019-03-08T17:16:30Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to extract a number from string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-a-number-from-string/m-p/265189#M79723</link>
      <description>&lt;P&gt;thanks for the help&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 17:16:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-a-number-from-string/m-p/265189#M79723</guid>
      <dc:creator>ramark</dc:creator>
      <dc:date>2019-03-08T17:16:50Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to extract a number from string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-a-number-from-string/m-p/265190#M79724</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;"GET \/ HTTP\/\d.\d" (?&amp;lt;Number&amp;gt;\d{3})
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Not sure why the named group got missed in my response.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 17:17:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-extract-a-number-from-string/m-p/265190#M79724</guid>
      <dc:creator>macadminrohit</dc:creator>
      <dc:date>2019-03-08T17:17:56Z</dc:date>
    </item>
  </channel>
</rss>

