<?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 not yielding result in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Rex-not-yielding-result/m-p/656916#M226894</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/253194"&gt;@harryhcg&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;as also&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;&amp;nbsp;hinted, you have to add another backslash to the regex:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex "RETURN\\\\\"\:\\\\\"(?&amp;lt;Field2&amp;gt;[^\\]+)"&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
    <pubDate>Thu, 07 Sep 2023 06:34:29 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2023-09-07T06:34:29Z</dc:date>
    <item>
      <title>Rex not yielding result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-not-yielding-result/m-p/656757#M226833</link>
      <description>&lt;P&gt;Data:&amp;nbsp;{"Field1":"xxx","message1":"{0}","message2":"xxx","message3":{"TEXT":"xxxx: xxx\r\n.xxxxx: {\"xxxxx\":{\"@CDI\":\"@ABC-123G-dhskdd-ghdkshd122@hkfhksdf12-djkshd12-hkdshd12 \",\"@RETURN\":\"&lt;STRONG&gt;xxxx-xxxxxxxxxx-xx-xxxxx&lt;/STRONG&gt;\",\"@message4\":\"xxxxxx:xxx\",\"message5\":{\"message6............&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Want to extract new field highlighted above but not getting any result.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I tried:&lt;/P&gt;&lt;P&gt;| rex field=_raw "RETURN\\\"\:\\\"(?&amp;lt;Field2&amp;gt;[^\\]+)"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2023 05:05:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-not-yielding-result/m-p/656757#M226833</guid>
      <dc:creator>harryhcg</dc:creator>
      <dc:date>2023-09-06T05:05:59Z</dc:date>
    </item>
    <item>
      <title>Re: Rex not yielding result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-not-yielding-result/m-p/656768#M226839</link>
      <description>&lt;P&gt;As I always tell people, do not treat structured data as plain text, and rex is not the right tool for JSON.&lt;/P&gt;&lt;P&gt;Looking at your illustration, I am convinced that your original data is fully compliant; the field message3.TEXT embeds an escaped, fully compliant JSON message with some leading text. &amp;nbsp;Like thus&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{"Field1":"xxx","message1":"{0}","message2":"xxx","message3":{"TEXT":"xxxx: xxx\r\n.xxxxx: {\"xxxxx\":{\"@CDI\":\"@ABC-123G-dhskdd-ghdkshd122@hkfhksdf12-djkshd12-hkdshd12 \",\"@RETURN\":\"xxxx-xxxxxxxxxx-xx-xxxxx\",\"@message4\":\"xxxxxx:xxx\",\"message5\":{\"message6\":null}}}"}}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As such, you can use this to directly access the field RETURN&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval TEXT = replace('message3.TEXT', "^[^{]+", "")
| spath input=TEXT path="xxxxx.@RETURN" output=Field2&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;The illustrated data will give something like&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Field1&lt;/TD&gt;&lt;TD&gt;Field2&lt;/TD&gt;&lt;TD&gt;message1&lt;/TD&gt;&lt;TD&gt;message2&lt;/TD&gt;&lt;TD&gt;message3.TEXT&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;xxx&lt;/TD&gt;&lt;TD&gt;xxxx-xxxxxxxxxx-xx-xxxxx&lt;/TD&gt;&lt;TD&gt;{0}&lt;/TD&gt;&lt;TD&gt;xxx&lt;/TD&gt;&lt;TD&gt;xxxx: xxx .xxxxx: {"xxxxx":{"@CDI":"@ABC-123G-dhskdd-ghdkshd122@hkfhksdf12-djkshd12-hkdshd12 ","@RETURN":"xxxx-xxxxxxxxxx-xx-xxxxx","@message4":"xxxxxx:xxx","message5":{"message6":null}}}&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Here is an emulation you can play with and compare with raw data&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw = "{\"Field1\":\"xxx\",\"message1\":\"{0}\",\"message2\":\"xxx\",\"message3\":{\"TEXT\":\"xxxx: xxx\\r\\n.xxxxx: {\\\"xxxxx\\\":{\\\"@CDI\\\":\\\"@ABC-123G-dhskdd-ghdkshd122@hkfhksdf12-djkshd12-hkdshd12 \\\",\\\"@RETURN\\\":\\\"xxxx-xxxxxxxxxx-xx-xxxxx\\\",\\\"@message4\\\":\\\"xxxxxx:xxx\\\",\\\"message5\\\":{\\\"message6\\\":null}}}\"}}"
| spath
``` data emulation above ```&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2023 06:19:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-not-yielding-result/m-p/656768#M226839</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-09-06T06:19:53Z</dc:date>
    </item>
    <item>
      <title>Re: Rex not yielding result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-not-yielding-result/m-p/656774#M226844</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/253194"&gt;@harryhcg&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;this seems to be a json format, so, as&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;&amp;nbsp;hinted, try to use the "spath" command (&lt;A href="https://community.splunk.com/t5/Splunk-Enterprise/spath-command/m-p/518343" target="_blank"&gt;https://community.splunk.com/t5/Splunk-Enterprise/spath-command/m-p/518343&lt;/A&gt;) .&lt;/P&gt;&lt;P&gt;About your regex, try to add another backslash to your regex:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex "RETURN\\\\"\:\\\\"(?&amp;lt;Field2&amp;gt;[^\\]+)"&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2023 06:43:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-not-yielding-result/m-p/656774#M226844</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-09-06T06:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: Rex not yielding result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-not-yielding-result/m-p/656789#M226851</link>
      <description>&lt;P&gt;Regarding regex suggestion, still have issue.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Error - Regex: missing terminating ] for character class.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Analysing&lt;SPAN&gt;&amp;nbsp;raw data to use spath. Thank you&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2023 08:50:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-not-yielding-result/m-p/656789#M226851</guid>
      <dc:creator>harryhcg</dc:creator>
      <dc:date>2023-09-06T08:50:01Z</dc:date>
    </item>
    <item>
      <title>Re: Rex not yielding result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-not-yielding-result/m-p/656791#M226853</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/253194"&gt;@harryhcg&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;let us know if we can help you more, or, please, accept one answer for the other people of Community.&lt;/P&gt;&lt;P&gt;Ciao and happy splunking&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;&lt;P&gt;P.S.: Karma Points are appreciated by all the contributors &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2023 08:59:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-not-yielding-result/m-p/656791#M226853</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-09-06T08:59:18Z</dc:date>
    </item>
    <item>
      <title>Re: Rex not yielding result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-not-yielding-result/m-p/656792#M226854</link>
      <description>&lt;P&gt;Single field extraction still wondering why it didn't work.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2023 09:03:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-not-yielding-result/m-p/656792#M226854</guid>
      <dc:creator>harryhcg</dc:creator>
      <dc:date>2023-09-06T09:03:29Z</dc:date>
    </item>
    <item>
      <title>Re: Rex not yielding result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-not-yielding-result/m-p/656914#M226893</link>
      <description>&lt;P&gt;If you have to use regex, you will need more backslashes.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex "@RETURN\\\\\":\\\\\"(?&amp;lt;Field2&amp;gt;[^\\\]+)"&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 07 Sep 2023 06:31:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-not-yielding-result/m-p/656914#M226893</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-09-07T06:31:43Z</dc:date>
    </item>
    <item>
      <title>Re: Rex not yielding result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-not-yielding-result/m-p/656916#M226894</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/253194"&gt;@harryhcg&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;as also&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;&amp;nbsp;hinted, you have to add another backslash to the regex:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex "RETURN\\\\\"\:\\\\\"(?&amp;lt;Field2&amp;gt;[^\\]+)"&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 06:34:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-not-yielding-result/m-p/656916#M226894</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-09-07T06:34:29Z</dc:date>
    </item>
    <item>
      <title>Re: Rex not yielding result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-not-yielding-result/m-p/656940#M226905</link>
      <description>&lt;P&gt;While I wholeheartedly agree with the "don't use regex for structured data" it's worth noting that sometimes it's not easy to extract the structured part from the whole event.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 09:15:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-not-yielding-result/m-p/656940#M226905</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2023-09-07T09:15:17Z</dc:date>
    </item>
  </channel>
</rss>

