<?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: field extraction between brackets in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/field-extraction-between-brackets/m-p/460287#M129833</link>
    <description>&lt;P&gt;@mehrdad_2000 &lt;/P&gt;

&lt;P&gt;You can try this also.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw=" A[1020/09/09] B[1013/09/09] C[05-07-00000000-000-A-B-C]" 
| rex field=_raw "A\[(?&amp;lt;A&amp;gt;[^\]]+)\]\sB\[(?&amp;lt;B&amp;gt;[^\]]+)\]\sC\[(?&amp;lt;C&amp;gt;[^\]]+)\]"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you want to split values in multivalued or space separated then add below search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval A1=split(A,"/"),A2=replace(A,"/"," ")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;if you want to get multi values in different fields then use below search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval x=mvindex(A1,0), y=mvindex(A1,1), z=mvindex(A1,2)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Wed, 11 Dec 2019 10:26:12 GMT</pubDate>
    <dc:creator>kamlesh_vaghela</dc:creator>
    <dc:date>2019-12-11T10:26:12Z</dc:date>
    <item>
      <title>field extraction between brackets</title>
      <link>https://community.splunk.com/t5/Splunk-Search/field-extraction-between-brackets/m-p/460285#M129831</link>
      <description>&lt;P&gt;I have log file like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;A[1020/09/09] B[1013/09/09] C[05-07-00000000-000-A-B-C]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;want to extract field of A, B, C.&lt;/P&gt;

&lt;P&gt;1-How can I extract content between brackets [] ? as you see in each brackets have (dash or slash ...) &lt;BR /&gt;
2-How can I extract fields as it could be single part "1020/09/09" or split like this "1020" "09" "09"&lt;/P&gt;

&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2019 09:53:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/field-extraction-between-brackets/m-p/460285#M129831</guid>
      <dc:creator>indeed_2000</dc:creator>
      <dc:date>2019-12-11T09:53:00Z</dc:date>
    </item>
    <item>
      <title>Re: field extraction between brackets</title>
      <link>https://community.splunk.com/t5/Splunk-Search/field-extraction-between-brackets/m-p/460286#M129832</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;Check this. if not, please specify your expected results.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval test="A[1020/09/09] B[1013/09/09] C[05-07-00000000-000-A-B-C]" 
| eval temp=split(test," ") 
| rex field=temp "\[(?P&amp;lt;output&amp;gt;.+)\]"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 Dec 2019 10:02:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/field-extraction-between-brackets/m-p/460286#M129832</guid>
      <dc:creator>vnravikumar</dc:creator>
      <dc:date>2019-12-11T10:02:49Z</dc:date>
    </item>
    <item>
      <title>Re: field extraction between brackets</title>
      <link>https://community.splunk.com/t5/Splunk-Search/field-extraction-between-brackets/m-p/460287#M129833</link>
      <description>&lt;P&gt;@mehrdad_2000 &lt;/P&gt;

&lt;P&gt;You can try this also.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw=" A[1020/09/09] B[1013/09/09] C[05-07-00000000-000-A-B-C]" 
| rex field=_raw "A\[(?&amp;lt;A&amp;gt;[^\]]+)\]\sB\[(?&amp;lt;B&amp;gt;[^\]]+)\]\sC\[(?&amp;lt;C&amp;gt;[^\]]+)\]"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you want to split values in multivalued or space separated then add below search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval A1=split(A,"/"),A2=replace(A,"/"," ")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;if you want to get multi values in different fields then use below search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval x=mvindex(A1,0), y=mvindex(A1,1), z=mvindex(A1,2)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2019 10:26:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/field-extraction-between-brackets/m-p/460287#M129833</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-12-11T10:26:12Z</dc:date>
    </item>
    <item>
      <title>Re: field extraction between brackets</title>
      <link>https://community.splunk.com/t5/Splunk-Search/field-extraction-between-brackets/m-p/460288#M129834</link>
      <description>&lt;P&gt;I'd not suggest using &lt;CODE&gt;.+&lt;/CODE&gt;, but simply use &lt;CODE&gt;[^\]]+&lt;/CODE&gt;. For a single event like this, that reduces the number of steps needed to evaluate from 171 to just 21 as it completely removes the need for backtracking.&lt;BR /&gt;
&lt;CODE&gt;A\[(?&amp;lt;A&amp;gt;.+)\]\sB\[(?&amp;lt;B&amp;gt;.+)\]\sC\[(?&amp;lt;C&amp;gt;.+)\]&lt;/CODE&gt; &lt;A href="https://regex101.com/r/7T5u9C/1"&gt;https://regex101.com/r/7T5u9C/1&lt;/A&gt;&lt;BR /&gt;
&lt;CODE&gt;A\[(?&amp;lt;A&amp;gt;[^\]]+)\]\sB\[(?&amp;lt;B&amp;gt;[^\]]+)\]\sC\[(?&amp;lt;C&amp;gt;[^\]]+)\]&lt;/CODE&gt; &lt;A href="https://regex101.com/r/AY9qew/1"&gt;https://regex101.com/r/AY9qew/1&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Have a look at the debugger on how bad &lt;CODE&gt;.+&lt;/CODE&gt; behaves: &lt;A href="https://regex101.com/r/7T5u9C/1/debugger"&gt;https://regex101.com/r/7T5u9C/1/debugger&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2019 11:56:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/field-extraction-between-brackets/m-p/460288#M129834</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2019-12-11T11:56:50Z</dc:date>
    </item>
    <item>
      <title>Re: field extraction between brackets</title>
      <link>https://community.splunk.com/t5/Splunk-Search/field-extraction-between-brackets/m-p/460289#M129835</link>
      <description>&lt;P&gt;Same here: don't use &lt;CODE&gt;.+&lt;/CODE&gt; if you don't have to. See my other comment for the reason why.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2019 11:57:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/field-extraction-between-brackets/m-p/460289#M129835</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2019-12-11T11:57:33Z</dc:date>
    </item>
    <item>
      <title>Re: field extraction between brackets</title>
      <link>https://community.splunk.com/t5/Splunk-Search/field-extraction-between-brackets/m-p/460290#M129836</link>
      <description>&lt;P&gt;Cool @FrankVl . Thanks for the regex optimization.  You regex improved with many steps. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
 I have updated my answer with new one. &lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2019 15:41:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/field-extraction-between-brackets/m-p/460290#M129836</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-12-11T15:41:07Z</dc:date>
    </item>
  </channel>
</rss>

