<?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: rex to extract particular field in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/rex-to-extract-particular-field/m-p/324327#M4599</link>
    <description>&lt;P&gt;If your event will have HCM5250 always, then:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex "&amp;lt;responseCode&amp;gt;(?P&amp;lt;responseCode&amp;gt;\d+)[\s\S]+HCM5250:(?P&amp;lt;responseMessage&amp;gt;[^&amp;lt;]+)&amp;lt;"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex "&amp;lt;responseCode&amp;gt;(?P&amp;lt;responseCode&amp;gt;\d+)[\s\S]+HCM5250:(?P&amp;lt;responseMessage&amp;gt;\w+)&amp;lt;"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Given the data as shown, either of these should work. If your data for the message is more generic, but you want the : to the end of the XML field, then try:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex "&amp;lt;responseCode&amp;gt;(?P&amp;lt;responseCode&amp;gt;\d+)[\s\S]+&amp;lt;responseMessage&amp;gt;[^&amp;lt;]*?:(?P&amp;lt;responseMessage&amp;gt;[^&amp;lt;]+)&amp;lt;"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 24 Jul 2017 22:31:16 GMT</pubDate>
    <dc:creator>cpetterborg</dc:creator>
    <dc:date>2017-07-24T22:31:16Z</dc:date>
    <item>
      <title>rex to extract particular field</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/rex-to-extract-particular-field/m-p/324324#M4596</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;

&lt;P&gt;I have below string and  need to extract field after HCM5250: and before .&lt;BR /&gt;
Also, while doing search need to consider  65. &lt;BR /&gt;
Both response Code and responseMessage written on separate lines &lt;/P&gt;

&lt;P&gt;65&lt;BR /&gt;
  updateContractTxnAccount Failed - update HCM5250:AD1218494460121708&lt;/P&gt;

&lt;P&gt;For e.g:&lt;/P&gt;

&lt;P&gt;index=mylog  "65" AND "updateContractTxnAccount Failed - update HCM5250:" |rex &lt;/P&gt;

&lt;P&gt;Not sure how to get exact rex here . Appreciate your help !!&lt;/P&gt;

&lt;P&gt;Thanks ,&lt;/P&gt;

&lt;P&gt;Harish&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2017 20:43:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/rex-to-extract-particular-field/m-p/324324#M4596</guid>
      <dc:creator>harishnpandey</dc:creator>
      <dc:date>2017-07-24T20:43:13Z</dc:date>
    </item>
    <item>
      <title>Re: rex to extract particular field</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/rex-to-extract-particular-field/m-p/324325#M4597</link>
      <description>&lt;PRE&gt;&lt;CODE&gt; &amp;lt;responseCode&amp;gt;65&amp;lt;/responseCode&amp;gt;
  &amp;lt;responseMessage&amp;gt;updateContractTxnAccount Failed - update HCM5250:AD1218494460121708&amp;lt;/responseMessage&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Jul 2017 21:01:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/rex-to-extract-particular-field/m-p/324325#M4597</guid>
      <dc:creator>harishnpandey</dc:creator>
      <dc:date>2017-07-24T21:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: rex to extract particular field</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/rex-to-extract-particular-field/m-p/324326#M4598</link>
      <description>&lt;P&gt;Is this an actual sample event you pasted here?&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2017 22:12:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/rex-to-extract-particular-field/m-p/324326#M4598</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2017-07-24T22:12:52Z</dc:date>
    </item>
    <item>
      <title>Re: rex to extract particular field</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/rex-to-extract-particular-field/m-p/324327#M4599</link>
      <description>&lt;P&gt;If your event will have HCM5250 always, then:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex "&amp;lt;responseCode&amp;gt;(?P&amp;lt;responseCode&amp;gt;\d+)[\s\S]+HCM5250:(?P&amp;lt;responseMessage&amp;gt;[^&amp;lt;]+)&amp;lt;"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex "&amp;lt;responseCode&amp;gt;(?P&amp;lt;responseCode&amp;gt;\d+)[\s\S]+HCM5250:(?P&amp;lt;responseMessage&amp;gt;\w+)&amp;lt;"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Given the data as shown, either of these should work. If your data for the message is more generic, but you want the : to the end of the XML field, then try:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex "&amp;lt;responseCode&amp;gt;(?P&amp;lt;responseCode&amp;gt;\d+)[\s\S]+&amp;lt;responseMessage&amp;gt;[^&amp;lt;]*?:(?P&amp;lt;responseMessage&amp;gt;[^&amp;lt;]+)&amp;lt;"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Jul 2017 22:31:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/rex-to-extract-particular-field/m-p/324327#M4599</guid>
      <dc:creator>cpetterborg</dc:creator>
      <dc:date>2017-07-24T22:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: rex to extract particular field</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/rex-to-extract-particular-field/m-p/324328#M4600</link>
      <description>&lt;P&gt;Below is my exact input stings out of which I need to extract only  "AD1218494460121708" which is txn account number..All transaction a/c I need to extract from log&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2017 13:29:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/rex-to-extract-particular-field/m-p/324328#M4600</guid>
      <dc:creator>harishnpandey</dc:creator>
      <dc:date>2017-07-25T13:29:30Z</dc:date>
    </item>
    <item>
      <title>Re: rex to extract particular field</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/rex-to-extract-particular-field/m-p/324329#M4601</link>
      <description>&lt;P&gt;harishnpandey,&lt;/P&gt;

&lt;P&gt;Did you mean to post the actual sample event?&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2017 14:22:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/rex-to-extract-particular-field/m-p/324329#M4601</guid>
      <dc:creator>bheemireddi</dc:creator>
      <dc:date>2017-07-25T14:22:03Z</dc:date>
    </item>
    <item>
      <title>Re: rex to extract particular field</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/rex-to-extract-particular-field/m-p/324330#M4602</link>
      <description>&lt;P&gt;Here is the rex you need if you only need the last part of the responseMessage:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex "&amp;lt;responseMessage&amp;gt;[^&amp;lt;]*?:(?P&amp;lt;fieldToBeExtracted_callMeWhatYouWant&amp;gt;[^&amp;lt;]+)&amp;lt;"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That should extract everything from after the colon (:) on to the end of the field.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2017 14:44:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/rex-to-extract-particular-field/m-p/324330#M4602</guid>
      <dc:creator>cpetterborg</dc:creator>
      <dc:date>2017-07-25T14:44:25Z</dc:date>
    </item>
  </channel>
</rss>

