<?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: Extracting an unknown number of fields with rex command? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-an-unknown-number-of-fields-with-rex-command/m-p/620647#M215759</link>
    <description>&lt;P&gt;I suspect that the OP meant separate &lt;EM&gt;events&lt;/EM&gt; rather than separate fields, like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex max_match=0 "NAME: (?&amp;lt;Name&amp;gt;\S+)"
| mvexpand Name&lt;/LI-CODE&gt;&lt;P&gt;But to humor the literal interpretation, you could do something like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex max_match=0 "NAME: (?&amp;lt;Name&amp;gt;\S+)"
| foreach 1 2 3 4 5 6 7 8 9 10 ``` more than mvcount(Name) ```
  [eval "Name-&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;" = mvindex(Name, &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; - 1)]&lt;/LI-CODE&gt;&lt;P&gt;This uses a side effect of SPL's handling of null assignments. (I wish the new multivalue foreach's &amp;lt;&amp;lt;ITEM&amp;gt;&amp;gt; could be used on the left-hand side. &amp;nbsp;It cannot.)&lt;/P&gt;</description>
    <pubDate>Sat, 12 Nov 2022 03:46:40 GMT</pubDate>
    <dc:creator>yuanliu</dc:creator>
    <dc:date>2022-11-12T03:46:40Z</dc:date>
    <item>
      <title>How to extract an unknown number of fields with rex command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-an-unknown-number-of-fields-with-rex-command/m-p/620639#M215756</link>
      <description>&lt;P&gt;Let's say I have data in an event that looks like this:&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;NAME: John
NAME: Mary 
NAME: Sue&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;Assuming I have no idea how many names will exist in the event, is it possible to use the rex command to parse out all the names and display them in separate fields?&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Jonathan&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2022 21:13:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-an-unknown-number-of-fields-with-rex-command/m-p/620639#M215756</guid>
      <dc:creator>jbrenner</dc:creator>
      <dc:date>2022-11-11T21:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting an unknown number of fields with rex command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-an-unknown-number-of-fields-with-rex-command/m-p/620640#M215757</link>
      <description>&lt;P&gt;You can use the &lt;FONT face="courier new,courier"&gt;rex&lt;/FONT&gt; command with the &lt;FONT face="courier new,courier"&gt;max_match&lt;/FONT&gt; option to match an unpredictable number of names.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex max_match=0 "NAME: (?&amp;lt;Name&amp;gt;\S+)"&lt;/LI-CODE&gt;&lt;P&gt;It will, however, put all of the matches into the single (multi-value) field called "Name".&amp;nbsp; You then can use the &lt;FONT face="courier new,courier"&gt;mvexpand&lt;/FONT&gt; command to put each Name value into a separate event.&amp;nbsp; That's not exactly "separate fields", though, is it?&lt;/P&gt;&lt;P&gt;What exactly do you mean by "separate fields"?&amp;nbsp; What should the final result look like?&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2022 20:59:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-an-unknown-number-of-fields-with-rex-command/m-p/620640#M215757</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2022-11-11T20:59:22Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting an unknown number of fields with rex command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-an-unknown-number-of-fields-with-rex-command/m-p/620647#M215759</link>
      <description>&lt;P&gt;I suspect that the OP meant separate &lt;EM&gt;events&lt;/EM&gt; rather than separate fields, like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex max_match=0 "NAME: (?&amp;lt;Name&amp;gt;\S+)"
| mvexpand Name&lt;/LI-CODE&gt;&lt;P&gt;But to humor the literal interpretation, you could do something like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex max_match=0 "NAME: (?&amp;lt;Name&amp;gt;\S+)"
| foreach 1 2 3 4 5 6 7 8 9 10 ``` more than mvcount(Name) ```
  [eval "Name-&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;" = mvindex(Name, &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; - 1)]&lt;/LI-CODE&gt;&lt;P&gt;This uses a side effect of SPL's handling of null assignments. (I wish the new multivalue foreach's &amp;lt;&amp;lt;ITEM&amp;gt;&amp;gt; could be used on the left-hand side. &amp;nbsp;It cannot.)&lt;/P&gt;</description>
      <pubDate>Sat, 12 Nov 2022 03:46:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-an-unknown-number-of-fields-with-rex-command/m-p/620647#M215759</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-11-12T03:46:40Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting an unknown number of fields with rex command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-an-unknown-number-of-fields-with-rex-command/m-p/620691#M215769</link>
      <description>&lt;P&gt;Another "technical" solution for making new fields is this, which first makes the name of the field, the name from the event, then uses streamstats to define the Name suffix, so doesn't have a foreach limitation.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw="NAME: John
NAME: Mary 
NAME: Sue
NAME: Jack
NAME: Jill
NAME: Peter
NAME: Susan"
| rex max_match=0 "NAME: (?&amp;lt;Name&amp;gt;\S+)"
| mvexpand Name
| streamstats c
| eval x_{Name}=c
| stats values(x_*) as *
| foreach * [ eval "Name_{&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;}"="&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;" ]
| fields Name_*&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;I say "technical", as this type of solution is rarely a real-life solution where mvexpand is an option in a large data set.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 13 Nov 2022 22:42:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-an-unknown-number-of-fields-with-rex-command/m-p/620691#M215769</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-11-13T22:42:54Z</dc:date>
    </item>
  </channel>
</rss>

