<?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 To extract a field using the REX Command in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/To-extract-a-field-using-the-REX-Command/m-p/674058#M230749</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;I want to extract the field issrDsclsrReqId"&amp;nbsp;using the Rex command.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone please help me with the command to extract the value of&amp;nbsp;field&amp;nbsp;bizMsgIdr&amp;nbsp; which is eiifr000005229220231229162227.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{ "shrhldrsIdDsclsrRspn": { "dsclsrRspnId": "0000537ede1c5e1084490000aa7eefab", "issrDsclsrReqRef": { "issrDsclsrReqId": "eiifr000005229220231229162227", "finInstrmId": { "isin": "FR0000052292" }, "shrhldrsDsclsrRcrdDt": { "dt": { "dt": "2023-12-29" } } }, "pgntn": { "lastPgInd": true, "pgNb": "1" }, "rspndgIntrmy": { "ctctPrsn": { "emailAdr": "ipb.asset.servicing@bnpparibas.com", "nm": "IPB ASSET SERVICING" }, "id": { "anyBIC": "BNPAGB22PBG" }, "nmAndAdr": { "adr": { "adrTp": 0, "bldgNb": "10", "ctry": "GB", "ctrySubDvsn": "LONDON", "pstCd": "NW16AA", "strtNm": "HAREWOOD AVENUE", "twnNm": "LONDON" }, "nm": "BNP PARIBAS PRIME BROKERAGE" } } } }&lt;/P&gt;</description>
    <pubDate>Fri, 12 Jan 2024 15:14:01 GMT</pubDate>
    <dc:creator>Real_captain</dc:creator>
    <dc:date>2024-01-12T15:14:01Z</dc:date>
    <item>
      <title>To extract a field using the REX Command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/To-extract-a-field-using-the-REX-Command/m-p/674058#M230749</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;I want to extract the field issrDsclsrReqId"&amp;nbsp;using the Rex command.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone please help me with the command to extract the value of&amp;nbsp;field&amp;nbsp;bizMsgIdr&amp;nbsp; which is eiifr000005229220231229162227.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{ "shrhldrsIdDsclsrRspn": { "dsclsrRspnId": "0000537ede1c5e1084490000aa7eefab", "issrDsclsrReqRef": { "issrDsclsrReqId": "eiifr000005229220231229162227", "finInstrmId": { "isin": "FR0000052292" }, "shrhldrsDsclsrRcrdDt": { "dt": { "dt": "2023-12-29" } } }, "pgntn": { "lastPgInd": true, "pgNb": "1" }, "rspndgIntrmy": { "ctctPrsn": { "emailAdr": "ipb.asset.servicing@bnpparibas.com", "nm": "IPB ASSET SERVICING" }, "id": { "anyBIC": "BNPAGB22PBG" }, "nmAndAdr": { "adr": { "adrTp": 0, "bldgNb": "10", "ctry": "GB", "ctrySubDvsn": "LONDON", "pstCd": "NW16AA", "strtNm": "HAREWOOD AVENUE", "twnNm": "LONDON" }, "nm": "BNP PARIBAS PRIME BROKERAGE" } } } }&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2024 15:14:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/To-extract-a-field-using-the-REX-Command/m-p/674058#M230749</guid>
      <dc:creator>Real_captain</dc:creator>
      <dc:date>2024-01-12T15:14:01Z</dc:date>
    </item>
    <item>
      <title>Re: To extract a field using the REX Command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/To-extract-a-field-using-the-REX-Command/m-p/674063#M230750</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;why not this way?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval _raw = "{ \"shrhldrsIdDsclsrRspn\": { \"dsclsrRspnId\": \"0000537ede1c5e1084490000aa7eefab\", \"issrDsclsrReqRef\": { \"issrDsclsrReqId\": \"eiifr000005229220231229162227\", \"finInstrmId\": { \"isin\": \"FR0000052292\" }, \"shrhldrsDsclsrRcrdDt\": { \"dt\": { \"dt\": \"2023-12-29\" } } }, \"pgntn\": { \"lastPgInd\": true, \"pgNb\": \"1\" }, \"rspndgIntrmy\": { \"ctctPrsn\": { \"emailAdr\": \"ipb.asset.servicing@bnpparibas.com\", \"nm\": \"IPB ASSET SERVICING\" }, \"id\": { \"anyBIC\": \"BNPAGB22PBG\" }, \"nmAndAdr\": { \"adr\": { \"adrTp\": 0, \"bldgNb\": \"10\", \"ctry\": \"GB\", \"ctrySubDvsn\": \"LONDON\", \"pstCd\": \"NW16AA\", \"strtNm\": \"HAREWOOD AVENUE\", \"twnNm\": \"LONDON\" }, \"nm\": \"BNP PARIBAS PRIME BROKERAGE\" } } } }"
``` generate test data``` 
| spath
| table shrhldrsIdDsclsrRspn.issrDsclsrReqRef.issrDsclsrReqId&lt;/LI-CODE&gt;&lt;P&gt;If needed you can also use spath function with eval.&lt;/P&gt;&lt;P&gt;If you really want to use rex then this should work&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval _raw = "{ \"shrhldrsIdDsclsrRspn\": { \"dsclsrRspnId\": \"0000537ede1c5e1084490000aa7eefab\", \"issrDsclsrReqRef\": { \"issrDsclsrReqId\": \"eiifr000005229220231229162227\", \"finInstrmId\": { \"isin\": \"FR0000052292\" }, \"shrhldrsDsclsrRcrdDt\": { \"dt\": { \"dt\": \"2023-12-29\" } } }, \"pgntn\": { \"lastPgInd\": true, \"pgNb\": \"1\" }, \"rspndgIntrmy\": { \"ctctPrsn\": { \"emailAdr\": \"ipb.asset.servicing@bnpparibas.com\", \"nm\": \"IPB ASSET SERVICING\" }, \"id\": { \"anyBIC\": \"BNPAGB22PBG\" }, \"nmAndAdr\": { \"adr\": { \"adrTp\": 0, \"bldgNb\": \"10\", \"ctry\": \"GB\", \"ctrySubDvsn\": \"LONDON\", \"pstCd\": \"NW16AA\", \"strtNm\": \"HAREWOOD AVENUE\", \"twnNm\": \"LONDON\" }, \"nm\": \"BNP PARIBAS PRIME BROKERAGE\" } } } }"
``` generate test data``` 
| rex "\"issrDsclsrReqId\"\s*:\s*\"(?&amp;lt;issrDsclsrReqId&amp;gt;[^\"]+)\""
| table  issrDsclsrReqId&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;r. Ismo&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2024 15:48:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/To-extract-a-field-using-the-REX-Command/m-p/674063#M230750</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2024-01-12T15:48:20Z</dc:date>
    </item>
    <item>
      <title>Re: To extract a field using the REX Command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/To-extract-a-field-using-the-REX-Command/m-p/674071#M230751</link>
      <description>&lt;P&gt;This is not working and no result in the column&amp;nbsp;issrDsclsrReqId.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it possible to extract the value of&amp;nbsp; "bizMsgIdr": from the field&amp;nbsp;&lt;STRONG&gt;Properties.appHdr&lt;/STRONG&gt; ?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Splunk COmmand :&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;`macro_events_prod_srt_shareholders_esa` sourcetype ="mscs:azure:eventhub" Name="Received Disclosure Response Command" "res1caf3c2ac2b3b6d180ff0001aa7eefab".&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Result in the column&amp;nbsp;&lt;STRONG&gt;Properties.appHdr :&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{
"fr": {
"fiId": {
"finInstnId": {
"bicfi": "BNPAGB22PBG"
}
}
},
"to": {
"fiId": {
"finInstnId": {
"bicfi": "SICVFRPPEII"
}
}
},
"bizMsgIdr": "res1caf3c2ac2b3b6d180ff0001aa7eefab",
"msgDefIdr": "seev.047.001.02",
"creDt": "2024-01-11T21:03:56.000Z"
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Real_captain_0-1705075471568.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28892i08F9EB1561B19042/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Real_captain_0-1705075471568.png" alt="Real_captain_0-1705075471568.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2024 16:54:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/To-extract-a-field-using-the-REX-Command/m-p/674071#M230751</guid>
      <dc:creator>Real_captain</dc:creator>
      <dc:date>2024-01-12T16:54:22Z</dc:date>
    </item>
    <item>
      <title>Re: To extract a field using the REX Command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/To-extract-a-field-using-the-REX-Command/m-p/674075#M230752</link>
      <description>&lt;P&gt;If this is json, like you already has, it's easier and better to use spath to extract those.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Based on your screenshot you should have this already on field&amp;nbsp;Properties.appHdr.bizMsgIdr . In that case you can try e.g&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;...
|rename Properties.appHdr.bizMsgIdr as bizMsgIdr&lt;/LI-CODE&gt;&lt;P&gt;if you really need to rename/use short version. Another option is use&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;...
| eval bizMsgIdr = Properties.appHdr.bizMsgIdr&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2024 16:25:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/To-extract-a-field-using-the-REX-Command/m-p/674075#M230752</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2024-01-12T16:25:30Z</dc:date>
    </item>
    <item>
      <title>Re: To extract a field using the REX Command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/To-extract-a-field-using-the-REX-Command/m-p/674080#M230753</link>
      <description>&lt;P&gt;It's generally &lt;EM&gt;not&lt;/EM&gt; the best idea to manipulate structured data with regexes if you can use the built-in functionality for handling the structure - like spath command or auto-kv functionality. Even if your data is guaranteed to be simple (you will never have an array or subobject as value), you don't have to worry of finding proper field boundaries, escaping and so on.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2024 16:59:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/To-extract-a-field-using-the-REX-Command/m-p/674080#M230753</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2024-01-12T16:59:11Z</dc:date>
    </item>
    <item>
      <title>Re: To extract a field using the REX Command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/To-extract-a-field-using-the-REX-Command/m-p/674228#M230786</link>
      <description>&lt;P&gt;Both these options are not working and splunk is not able to extract the&amp;nbsp;bizMsgIdr from the field&amp;nbsp;Properties.appHdr .&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please provide some other way to extract this text.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Real_captain_0-1705307484920.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28923iBD3BDED34F59955B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Real_captain_0-1705307484920.png" alt="Real_captain_0-1705307484920.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2024 08:32:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/To-extract-a-field-using-the-REX-Command/m-p/674228#M230786</guid>
      <dc:creator>Real_captain</dc:creator>
      <dc:date>2024-01-15T08:32:21Z</dc:date>
    </item>
    <item>
      <title>Re: To extract a field using the REX Command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/To-extract-a-field-using-the-REX-Command/m-p/674232#M230788</link>
      <description>&lt;P&gt;How about this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval Properties.appHdr = "{
  \"fr\": {
    \"fiId\": {
      \"finInstnId\": {
        \"bicfi\": \"BNPAGB22PBG\"
      }
    }
  },
  \"to\": {
    \"fiId\": {
      \"finInstnId\": {
        \"bicfi\": \"SICVFRPPEII\"
      }
    }
  },
  \"bizMsgIdr\": \"res1caf3c2ac2b3b6d180ff0001aa7eefab\",
  \"msgDefIdr\": \"seev.047.001.02\",
  \"creDt\": \"2024-01-11T21:03:56.000Z\"
}"
| fields - _time
```Generate test event```
| spath input=Properties.appHdr
| table bizMsgIdr *&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 15 Jan 2024 08:47:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/To-extract-a-field-using-the-REX-Command/m-p/674232#M230788</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2024-01-15T08:47:29Z</dc:date>
    </item>
  </channel>
</rss>

