<?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 field list of strings in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Rex-field-list-of-strings/m-p/576718#M200997</link>
    <description>&lt;P&gt;I managed to extract one field from the variable2-field. In some cases, it picks-up a 4-character-string, if a 6-character string is not present although I added match=0 to the query.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The cause looks that the order of the six-character and four-character strings within the list is unsorted. So this makes it more complicated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you have a suggestion to approach this?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 30 Nov 2021 08:43:15 GMT</pubDate>
    <dc:creator>tjdevries</dc:creator>
    <dc:date>2021-11-30T08:43:15Z</dc:date>
    <item>
      <title>Rex field list of strings</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-field-list-of-strings/m-p/576199#M200802</link>
      <description>&lt;P&gt;How do I extract all values from a json file containing a list with multiple strings with rex?&lt;/P&gt;&lt;P&gt;The content of the field contains a list and a variable in stringform.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The number of items in the list can vary and the length of items also.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The field is as follows:&lt;/P&gt;&lt;P&gt;"{\"variable2\":[\"AB1234\",\"BA1234\",\"DCBA\",\"ABCD\"],\"name\":\"namegiven\"}&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;In sofar, I was able to extract the field name with the following query. &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;| rex field=field.subfield.body max_match=0 "\"name\"\:\"(?&amp;lt;name&amp;gt;[a-zA-Z]+)\""&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Variable 2 is a list with multiple strings and this leaves me puzzled.&amp;nbsp;It's not the expression to recognize the strings in the list, but I'm looking for a way to look inside the list, look for two different patterns and find all items in it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone help out?&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 14:50:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-field-list-of-strings/m-p/576199#M200802</guid>
      <dc:creator>tjdevries</dc:creator>
      <dc:date>2021-11-24T14:50:28Z</dc:date>
    </item>
    <item>
      <title>Re: Rex field list of strings</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-field-list-of-strings/m-p/576204#M200805</link>
      <description>&lt;P&gt;May I suggest extracting the fields with rex and then parsing them in a separate command?&amp;nbsp; Perhaps this will get you started.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults | eval _raw="{\"variable2\":[\"AB1234\",\"BA1234\",\"DCBA\",\"ABCD\"],\"name\":\"namegiven\"}"
```Above just sets up test data```
| rex "variable2\\\":\[(?&amp;lt;variable2&amp;gt;[^\]]+)],\\\"name\\\":\\\"(?&amp;lt;name&amp;gt;[a-zA-Z]+)"
| eval variable2=split(variable2,",")
...&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 24 Nov 2021 15:15:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-field-list-of-strings/m-p/576204#M200805</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2021-11-24T15:15:29Z</dc:date>
    </item>
    <item>
      <title>Re: Rex field list of strings</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-field-list-of-strings/m-p/576369#M200872</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With &amp;nbsp;structured data like JSON, it is less desirable to use Rex for extraction. &amp;nbsp;Have you considered &lt;A href="https://docs.splunk.com/Documentation/Splunk/8.2.3/SearchReference/Spath" target="_blank" rel="noopener"&gt;spath&amp;nbsp;instead&lt;/A&gt;?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults ``` emulation ```
| eval myfield = "{\"variable2\":[\"AB1234\",\"BA1234\",\"DCBA\",\"ABCD\"],\"name\":\"namegiven\"}"


| spath input=myfield&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Nov 2021 23:55:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-field-list-of-strings/m-p/576369#M200872</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2021-11-25T23:55:28Z</dc:date>
    </item>
    <item>
      <title>Re: Rex field list of strings</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-field-list-of-strings/m-p/576717#M200996</link>
      <description>&lt;P&gt;Not yet but it looks a good approach to look into.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2021 08:37:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-field-list-of-strings/m-p/576717#M200996</guid>
      <dc:creator>tjdevries</dc:creator>
      <dc:date>2021-11-30T08:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: Rex field list of strings</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-field-list-of-strings/m-p/576718#M200997</link>
      <description>&lt;P&gt;I managed to extract one field from the variable2-field. In some cases, it picks-up a 4-character-string, if a 6-character string is not present although I added match=0 to the query.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The cause looks that the order of the six-character and four-character strings within the list is unsorted. So this makes it more complicated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you have a suggestion to approach this?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2021 08:43:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-field-list-of-strings/m-p/576718#M200997</guid>
      <dc:creator>tjdevries</dc:creator>
      <dc:date>2021-11-30T08:43:15Z</dc:date>
    </item>
    <item>
      <title>Re: Rex field list of strings</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-field-list-of-strings/m-p/576782#M201016</link>
      <description>&lt;P&gt;If the data is proper JSON, consider&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;'s suggestion and try the &lt;FONT face="courier new,courier"&gt;spath&lt;/FONT&gt; command.&lt;/P&gt;&lt;P&gt;I'm puzzled a bit by the latest response.&amp;nbsp; The regex doesn't care about the size of the strings, it just pulls everything from between the square brackets that follow "variable2".&amp;nbsp; Can you share actual events and search results (sanitized, of course)?&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2021 18:42:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-field-list-of-strings/m-p/576782#M201016</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2021-11-30T18:42:17Z</dc:date>
    </item>
  </channel>
</rss>

