<?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 Rex field from a field help in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Rex-field-from-a-field-help/m-p/751540#M242517</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am terrible at Regex and am in need of help on rexing a field from another field.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So an event snippet is:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;"InterfaceDocument" : "{\"MessageType\":\"ANY_ITM_ImportItems\",\"OrgId\":\"8103_DEV\",\"MessageId\":\"15834815630667925_PUBSUB\",\"ErrorCode\":\"fwe::10001\"&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;I need to create a field for everything between&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{\"MessageType\":\"&lt;/LI-CODE&gt;&lt;P&gt;and&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;\"OrgId\&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In my search I am using the following:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;rex field=InterfaceDocument "MessageType\":\"(?&amp;lt;Type&amp;gt;[^*])"&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;This only creates a field with the first letter "A".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Could anyone help me out on how I can get this to work right.&amp;nbsp; My apologies, again, I am not regex savvy at all. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Tom&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 13 Aug 2025 13:33:16 GMT</pubDate>
    <dc:creator>tdavison76</dc:creator>
    <dc:date>2025-08-13T13:33:16Z</dc:date>
    <item>
      <title>Rex field from a field help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-field-from-a-field-help/m-p/751540#M242517</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am terrible at Regex and am in need of help on rexing a field from another field.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So an event snippet is:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;"InterfaceDocument" : "{\"MessageType\":\"ANY_ITM_ImportItems\",\"OrgId\":\"8103_DEV\",\"MessageId\":\"15834815630667925_PUBSUB\",\"ErrorCode\":\"fwe::10001\"&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;I need to create a field for everything between&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{\"MessageType\":\"&lt;/LI-CODE&gt;&lt;P&gt;and&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;\"OrgId\&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In my search I am using the following:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;rex field=InterfaceDocument "MessageType\":\"(?&amp;lt;Type&amp;gt;[^*])"&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;This only creates a field with the first letter "A".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Could anyone help me out on how I can get this to work right.&amp;nbsp; My apologies, again, I am not regex savvy at all. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Tom&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Aug 2025 13:33:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-field-from-a-field-help/m-p/751540#M242517</guid>
      <dc:creator>tdavison76</dc:creator>
      <dc:date>2025-08-13T13:33:16Z</dc:date>
    </item>
    <item>
      <title>Re: Rex field from a field help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-field-from-a-field-help/m-p/751549#M242520</link>
      <description>&lt;P&gt;By default, a character class (anything inside square brackets) will match a single character.&amp;nbsp; That's why you get only "A".&amp;nbsp; Use a quantifier ('+' or '*') to match multiple characters.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;The current regex matches anything that is not an asterisk, which would be everything in the sample data.&amp;nbsp; I expect this is not the intent.&amp;nbsp; Try this regular expression, which matches up to the first backslash in the MessageType field.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;MessageType\\":\\"(?&amp;lt;Type&amp;gt;[^\\]+)&lt;/LI-CODE&gt;&lt;P&gt;Note: You probably will need to escape the embedded quotation marks in the expression to get it to work in SPL.&amp;nbsp; Because of the multiple layers of processing, multiple escapes are required - something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;MessageType\\\\\":\\\\\"(?&amp;lt;Type&amp;gt;[^\\]+)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Aug 2025 13:51:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-field-from-a-field-help/m-p/751549#M242520</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2025-08-13T13:51:54Z</dc:date>
    </item>
    <item>
      <title>Re: Rex field from a field help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-field-from-a-field-help/m-p/751550#M242521</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/267744"&gt;@tdavison76&lt;/a&gt;&amp;nbsp;try something like this?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; | rex field=InterfaceDocument "MessageType\":\"(?&amp;lt;MessageType&amp;gt;[^\"]*)"&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;If this Helps, Please Upvote.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Aug 2025 13:51:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-field-from-a-field-help/m-p/751550#M242521</guid>
      <dc:creator>sainag_splunk</dc:creator>
      <dc:date>2025-08-13T13:51:59Z</dc:date>
    </item>
    <item>
      <title>Re: Rex field from a field help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-field-from-a-field-help/m-p/751551#M242522</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/267744"&gt;@tdavison76&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;You can use the following regex in your rex command.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex field=InterfaceDocument "MessageType\\"\:\\\"(?&amp;lt;message_type&amp;gt;[\w\_\d]+)\\\",\\\"OrgId\\\"\:\\\"(?&amp;lt;org_id&amp;gt;[\w\d\_]+)\\\""&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;You can play around regex here -&amp;nbsp;&lt;A href="https://regex101.com/r/auuJ8u/1" target="_blank" rel="noopener"&gt;https://regex101.com/r/auuJ8u/1&lt;/A&gt;&lt;/P&gt;&lt;P&gt;For now, I've only captured alphabets, numbers, and underscores (_). If there are any other special characters that are part of either MessageType or OrgId, feel free to add them within the square brackets in the capturing group.&lt;/P&gt;&lt;P&gt;Thanks,&lt;BR /&gt;Tejas.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;---&lt;BR /&gt;If the above solution helps, an upvote is appreciated..!!&lt;/P&gt;</description>
      <pubDate>Wed, 13 Aug 2025 13:55:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-field-from-a-field-help/m-p/751551#M242522</guid>
      <dc:creator>tej57</dc:creator>
      <dc:date>2025-08-13T13:55:33Z</dc:date>
    </item>
    <item>
      <title>Re: Rex field from a field help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-field-from-a-field-help/m-p/751556#M242524</link>
      <description>&lt;P&gt;Getting the number of backslashes right in regex for rex commands can be tricky (as&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;&amp;nbsp;has already alluded to), especially as they are different to what is required by regex101.com! Try something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| fields - _time
| eval InterfaceDocument="\"InterfaceDocument\" : \"{\\\"MessageType\\\":\\\"ANY_ITM_ImportItems\\\",\\\"OrgId\\\":\\\"8103_DEV\\\",\\\"MessageId\\\":\\\"15834815630667925_PUBSUB\\\",\\\"ErrorCode\\\":\\\"fwe::10001\\\""
| rex field=InterfaceDocument "MessageType\\\\\":\\\\\"(?&amp;lt;Type&amp;gt;[^\\\\]+)"&lt;/LI-CODE&gt;&lt;P&gt;Having said that, these look like JSON fields, why don't you try using the json_ functions?&lt;/P&gt;</description>
      <pubDate>Wed, 13 Aug 2025 14:13:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-field-from-a-field-help/m-p/751556#M242524</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2025-08-13T14:13:06Z</dc:date>
    </item>
    <item>
      <title>Re: Rex field from a field help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-field-from-a-field-help/m-p/751575#M242528</link>
      <description>&lt;P&gt;Ugh. This seems like some kind of a string containing a JSON object as a field in another JSON object.&lt;/P&gt;&lt;P&gt;Why not use spath then?&lt;/P&gt;&lt;PRE&gt;| spath input=InterfaceDocument "MessageType"&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Aug 2025 15:26:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-field-from-a-field-help/m-p/751575#M242528</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2025-08-13T15:26:10Z</dc:date>
    </item>
    <item>
      <title>Re: Rex field from a field help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-field-from-a-field-help/m-p/751604#M242532</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/267744"&gt;@tdavison76&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can use below,&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex field=InterfaceDocument "\"MessageType\":\"(?&amp;lt;Type&amp;gt;[^\"]+)"&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="demo4.JPG" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/39960iB90EF7A4B8C3BC9A/image-size/large?v=v2&amp;amp;px=999" role="button" title="demo4.JPG" alt="demo4.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Prewin&lt;BR /&gt;Splunk Enthusiast | Always happy to help! If this answer helped you, please consider marking it as the solution or giving a Karma. Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 14 Aug 2025 04:41:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-field-from-a-field-help/m-p/751604#M242532</guid>
      <dc:creator>PrewinThomas</dc:creator>
      <dc:date>2025-08-14T04:41:21Z</dc:date>
    </item>
    <item>
      <title>Re: Rex field from a field help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-field-from-a-field-help/m-p/751615#M242534</link>
      <description>&lt;P&gt;Exactly. &amp;nbsp;If the raw event contains both non-JSON and JSON components, extract that JSON component first, then use spath to extract keys from JSON.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Aug 2025 06:56:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-field-from-a-field-help/m-p/751615#M242534</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2025-08-14T06:56:38Z</dc:date>
    </item>
  </channel>
</rss>

