<?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 to extract particular value using regular expression? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-particular-value-using-regular-expression/m-p/298748#M90048</link>
    <description>&lt;P&gt;this is working...thanks!&lt;/P&gt;

&lt;P&gt;now i am trying to put them in a field.&lt;/P&gt;</description>
    <pubDate>Tue, 14 Feb 2017 21:12:38 GMT</pubDate>
    <dc:creator>chetanhonnavile</dc:creator>
    <dc:date>2017-02-14T21:12:38Z</dc:date>
    <item>
      <title>How to extract particular value using regular expression?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-particular-value-using-regular-expression/m-p/298744#M90044</link>
      <description>&lt;P&gt;In the below event "status" key has the value either "1" or "0" . I am looking out to extract those "status" having the value "0" and put them in a field&lt;/P&gt;

&lt;P&gt;please help me out in getting a regular expression for this.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2017-02-14 18:47:28.572 INFO  SomePlaceHolder-5 [.abc.def.nothingishere]  - string response: &amp;lt;200 OK,{"clips":[{"myid":"123456","historyid":"777-888-999","provider":"somecompany","status":1,"userType":1}]},{X-Backside-Transport=[OK OK], Connection=[Keep-Alive], Transfer-Encoding=[chunked], Content-Type=[application/json], X-Powered-By=[ARR/3.0,ASP.NET], Date=[Tue, 14 Feb 2017 18:47:28 GMT], X-Client-IP=[10.0.0.0.], X-Global-Transaction-ID=[9876543]}&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Feb 2017 19:41:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-particular-value-using-regular-expression/m-p/298744#M90044</guid>
      <dc:creator>chetanhonnavile</dc:creator>
      <dc:date>2017-02-14T19:41:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract particular value using regular expression?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-particular-value-using-regular-expression/m-p/298745#M90045</link>
      <description>&lt;P&gt;Do you only want the ones with 0 as the value? This is the general solution:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex "\"state\":(?P&amp;lt;status&amp;gt;\d),"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Feb 2017 20:29:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-particular-value-using-regular-expression/m-p/298745#M90045</guid>
      <dc:creator>cpetterborg</dc:creator>
      <dc:date>2017-02-14T20:29:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract particular value using regular expression?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-particular-value-using-regular-expression/m-p/298746#M90046</link>
      <description>&lt;P&gt;Something like this, perhaps?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=foo | regex "\"status\":0" | ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Feb 2017 20:34:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-particular-value-using-regular-expression/m-p/298746#M90046</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2017-02-14T20:34:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract particular value using regular expression?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-particular-value-using-regular-expression/m-p/298747#M90047</link>
      <description>&lt;P&gt;yeah,looking for only status:0 &lt;/P&gt;

&lt;P&gt;well the query you provided  gives me the same number of events combining both 0's and 1's.&lt;/P&gt;

&lt;P&gt;if i am filtering it for only 0's then the event count will be too small.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2017 21:11:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-particular-value-using-regular-expression/m-p/298747#M90047</guid>
      <dc:creator>chetanhonnavile</dc:creator>
      <dc:date>2017-02-14T21:11:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract particular value using regular expression?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-particular-value-using-regular-expression/m-p/298748#M90048</link>
      <description>&lt;P&gt;this is working...thanks!&lt;/P&gt;

&lt;P&gt;now i am trying to put them in a field.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2017 21:12:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-particular-value-using-regular-expression/m-p/298748#M90048</guid>
      <dc:creator>chetanhonnavile</dc:creator>
      <dc:date>2017-02-14T21:12:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract particular value using regular expression?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-particular-value-using-regular-expression/m-p/298749#M90049</link>
      <description>&lt;P&gt;well this solution looks like regular regex.&lt;/P&gt;

&lt;P&gt;i am finding difficulty in understanding the 'rex' conventions used in splunk ,any good explanatory document at your end ?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2017 21:14:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-particular-value-using-regular-expression/m-p/298749#M90049</guid>
      <dc:creator>chetanhonnavile</dc:creator>
      <dc:date>2017-02-14T21:14:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract particular value using regular expression?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-particular-value-using-regular-expression/m-p/298750#M90050</link>
      <description>&lt;P&gt;Put precisely WHAT in a field?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2017 22:27:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-particular-value-using-regular-expression/m-p/298750#M90050</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-02-14T22:27:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract particular value using regular expression?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-particular-value-using-regular-expression/m-p/298751#M90051</link>
      <description>&lt;P&gt;If you just want a count, you can do this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ... | rex "\"state\":(?P&amp;lt;status&amp;gt;\d)," | search status=0 | stats count 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ... | rex "\"state\":(?P&amp;lt;status&amp;gt;0)," | where status=* | stats count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Feb 2017 23:19:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-particular-value-using-regular-expression/m-p/298751#M90051</guid>
      <dc:creator>cpetterborg</dc:creator>
      <dc:date>2017-02-14T23:19:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract particular value using regular expression?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-particular-value-using-regular-expression/m-p/298752#M90052</link>
      <description>&lt;P&gt;Have a read of the section regarding 'named capture groups' here:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://www.regular-expressions.info/named.html"&gt;http://www.regular-expressions.info/named.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;This should be a good starting point to see how the &lt;CODE&gt;rex&lt;/CODE&gt; command (not the &lt;CODE&gt;regex&lt;/CODE&gt; command), can be used to create field / value pairs.&lt;/P&gt;

&lt;P&gt;Building on the great answers above, think of it like this.&lt;/P&gt;

&lt;P&gt;Find the part of your string which you want to match, then wrap it in brackets.&lt;/P&gt;

&lt;P&gt;So if you wanted to find the digit after &lt;CODE&gt;"status":&lt;/CODE&gt; you could write:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"\"status\":(\d)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now if you want to give that a field name (lets call it 'status_value') using &lt;CODE&gt;rex&lt;/CODE&gt;, you could do:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"\"status\":(?&amp;lt;status_value&amp;gt;\d)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In Splunk, you should now have a field called 'status_value' containing the digit from your event.&lt;/P&gt;

&lt;P&gt;But the &lt;A href="http://www.regular-expressions.info"&gt;http://www.regular-expressions.info&lt;/A&gt; site is a great place to read up on regex in general.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 04:16:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-particular-value-using-regular-expression/m-p/298752#M90052</guid>
      <dc:creator>gvmorley</dc:creator>
      <dc:date>2017-02-15T04:16:39Z</dc:date>
    </item>
  </channel>
</rss>

