<?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: How do I extract and separate an arbitrary number of field values with regex? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-and-separate-an-arbitrary-number-of-field/m-p/139530#M38385</link>
    <description>&lt;P&gt;makemv suited my purposes. &lt;/P&gt;

&lt;P&gt;An arbitrary number of fields should be scalable. Your solution would be a bit messy if there were thousands of "tasks". Thanks though!&lt;/P&gt;</description>
    <pubDate>Wed, 29 Jul 2015 02:43:22 GMT</pubDate>
    <dc:creator>andrew207</dc:creator>
    <dc:date>2015-07-29T02:43:22Z</dc:date>
    <item>
      <title>How do I extract and separate an arbitrary number of field values with regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-and-separate-an-arbitrary-number-of-field/m-p/139527#M38382</link>
      <description>&lt;P&gt;input: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;myCommand -myArgs taska taskb taskc
myCommand -myArgs taska
myCommand -myArgs taska taskb taskc taskd
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What's the best way to capture this? At the moment I'm using the regex&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;myCommand (?P&amp;lt;args&amp;gt;\-\w+)(\s(?P&amp;lt;tasks&amp;gt;[A-z0-9\s]+))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It results in&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;1. tasks: "taska taskb taskc"
2. tasks: "taska"
3. tasks: "taska taskb taskc taskd"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How would I go about separating these or making them individual? I want to aggregate by "taska" and draw some nice graphs more easily.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jul 2015 03:24:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-and-separate-an-arbitrary-number-of-field/m-p/139527#M38382</guid>
      <dc:creator>andrew207</dc:creator>
      <dc:date>2015-07-28T03:24:08Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract and separate an arbitrary number of field values with regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-and-separate-an-arbitrary-number-of-field/m-p/139528#M38383</link>
      <description>&lt;P&gt;If you have 4 tasks, you can extract them separately in 4 columns -&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?P&amp;lt;args&amp;gt;\-\w+)\s+(?P&amp;lt;taskA&amp;gt;\w+)\s+(?P&amp;lt;taskB&amp;gt;\w+)\s+(?P&amp;lt;taskC&amp;gt;\w+)\s+(?P&amp;lt;taskD&amp;gt;\w+)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Jul 2015 06:18:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-and-separate-an-arbitrary-number-of-field/m-p/139528#M38383</guid>
      <dc:creator>dineshraj9</dc:creator>
      <dc:date>2015-07-28T06:18:49Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract and separate an arbitrary number of field values with regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-and-separate-an-arbitrary-number-of-field/m-p/139529#M38384</link>
      <description>&lt;P&gt;I don't think this is possible with regex in the sense of arbitrary number of capturing groups. You could of course define a high number of capturing groups and make them optional, something like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?&amp;lt;task1&amp;gt;\w+)(?:[ ])?(?&amp;lt;task2&amp;gt;\w+)?(?:[ ])?(?&amp;lt;task3&amp;gt;\w+)?(?:[ ])?(?&amp;lt;task4&amp;gt;\w+)?(?:[ ])?(?&amp;lt;task5&amp;gt;\w+)?
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It shouldn't matter if the latter groups don't match.&lt;/P&gt;

&lt;P&gt;But do you really need all those tasks as unique fields? What about the order they appear in, will that be fixed? Or, what if one event has task1=ab task2=cd and another event has task1=cd? You won't directly see that these two events both have a task "cd", but it is up to you to judge your needs.&lt;/P&gt;

&lt;P&gt;I would suggest you keep them as one field the way you have them now, and do &lt;CODE&gt;makemv tasks&lt;/CODE&gt; to have them in a multivalue field. That will allow you to compare them more easily and check which events contain which tasks.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jul 2015 06:48:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-and-separate-an-arbitrary-number-of-field/m-p/139529#M38384</guid>
      <dc:creator>jeffland</dc:creator>
      <dc:date>2015-07-28T06:48:35Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract and separate an arbitrary number of field values with regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-and-separate-an-arbitrary-number-of-field/m-p/139530#M38385</link>
      <description>&lt;P&gt;makemv suited my purposes. &lt;/P&gt;

&lt;P&gt;An arbitrary number of fields should be scalable. Your solution would be a bit messy if there were thousands of "tasks". Thanks though!&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2015 02:43:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-and-separate-an-arbitrary-number-of-field/m-p/139530#M38385</guid>
      <dc:creator>andrew207</dc:creator>
      <dc:date>2015-07-29T02:43:22Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract and separate an arbitrary number of field values with regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-and-separate-an-arbitrary-number-of-field/m-p/139531#M38386</link>
      <description>&lt;P&gt;And that's where regular expressions hit their limit - they don't support having an arbitrary number of capturing groups (not as far as I know, and quick googling reveals &lt;A href="http://stackoverflow.com/questions/3537878/how-to-capture-an-arbitrary-number-of-groups-in-javascript-regexp"&gt;this evidence&lt;/A&gt;).&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2015 07:43:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-and-separate-an-arbitrary-number-of-field/m-p/139531#M38386</guid>
      <dc:creator>jeffland</dc:creator>
      <dc:date>2015-07-29T07:43:46Z</dc:date>
    </item>
  </channel>
</rss>

