<?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: Unable to extract fields through regular expression and combining them into a single field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Unable-to-extract-fields-through-regular-expression-and/m-p/146768#M41011</link>
    <description>&lt;P&gt;Thanks that worked in my case &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
But i was just wondering what's that (?P) for?&lt;BR /&gt;
And suppose if that my log has "(null)" "none" "void" etc then? &lt;BR /&gt;
I thought to capture this also in a field with a regex, you know like an optional field? but it didn't really work. your suggestion did infact helped in my case but what if it was not the case and i had "(null)","none","void" not just "(null)" then?&lt;/P&gt;</description>
    <pubDate>Mon, 18 Nov 2013 19:28:54 GMT</pubDate>
    <dc:creator>luv</dc:creator>
    <dc:date>2013-11-18T19:28:54Z</dc:date>
    <item>
      <title>Unable to extract fields through regular expression and combining them into a single field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Unable-to-extract-fields-through-regular-expression-and/m-p/146766#M41009</link>
      <description>&lt;P&gt;2013-07-09-23.57.30 [SHU1_SCG1_20130913_UJDD] &lt;BR /&gt;
2013-07-09-23.57.45 [UBH2_SCDXC1_20130913_FDS]&lt;BR /&gt;
2013-07-09-23.57.56 [HS3_FDR1_20130924_DJUWS]&lt;BR /&gt;
2013-07-09-23.57.57 [GFD3_FIE1_20130927_AOIS]&lt;BR /&gt;
2013-07-09-23.58.00 [SHU1_DBXCF1_20130929_KIDD]&lt;BR /&gt;
2013-07-09-23.58.30 [(null)]&lt;BR /&gt;
2013-07-09-23.59.12 [(null)]&lt;BR /&gt;
2013-07-09-23.59.30 [LIFDSDSD1_DFFDFDF1_20131004_IWD]&lt;BR /&gt;
2013-07-09-23.59.56 [SDJER4_IUEHG1_20131009_SKIW]&lt;BR /&gt;
2013-08-09-02.58.30 [(null)]&lt;BR /&gt;
2013-08-09-04.18.40 [OEIFN3_SZXV1_20131013_APOS]&lt;BR /&gt;
2013-08-09-04.32.50 [OWPOPF2_VJGGG1_20131022_SIWD]&lt;/P&gt;

&lt;P&gt;Their arrangement is like [Field1_Feild2_Feild3_Field4] and sometimes the whole event is (null)&lt;BR /&gt;
Is there any way from which i can extract all the fields(field1,field2,field3,field4) through a single regex and also the null value(null) if it occurs?&lt;BR /&gt;
Also after extracting all these fields i want to combine them into a single field(Field5) and wanna show them like "Field5=Field1_Field2_Field3_Field4" or just "Field5=(null)" if that's the case&lt;/P&gt;

&lt;P&gt;Any advice?&lt;/P&gt;

&lt;P&gt;Thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:18:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Unable-to-extract-fields-through-regular-expression-and/m-p/146766#M41009</guid>
      <dc:creator>luv</dc:creator>
      <dc:date>2020-09-28T15:18:29Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to extract fields through regular expression and combining them into a single field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Unable-to-extract-fields-through-regular-expression-and/m-p/146767#M41010</link>
      <description>&lt;P&gt;You can use below to extract individual fields and then evaluate combined field.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;base search&amp;gt;| rex field=body "(?i)\[(?P&amp;lt;field1&amp;gt;.*)_(?P&amp;lt;field2&amp;gt;.*)_(?P&amp;lt;field3&amp;gt;.*)_(?P&amp;lt;field4&amp;gt;.*)\]" | eval field5=COALESCE(field1."_".field2."_".field3."_".field4,"(null)")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;H2&gt;Update:&lt;/H2&gt;

&lt;P&gt;To include field5 with values whatever is available.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;base search&amp;gt;| rex field=_raw "(?i)\[(?P&amp;lt;field1&amp;gt;.*)_(?P&amp;lt;field2&amp;gt;.*)_(?P&amp;lt;field3&amp;gt;.*)_(?P&amp;lt;field4&amp;gt;.*)\]" | rex field=_raw "(?i)\[(?P&amp;lt;field5&amp;gt;.*)\]"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Nov 2013 18:44:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Unable-to-extract-fields-through-regular-expression-and/m-p/146767#M41010</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2013-11-18T18:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to extract fields through regular expression and combining them into a single field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Unable-to-extract-fields-through-regular-expression-and/m-p/146768#M41011</link>
      <description>&lt;P&gt;Thanks that worked in my case &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
But i was just wondering what's that (?P) for?&lt;BR /&gt;
And suppose if that my log has "(null)" "none" "void" etc then? &lt;BR /&gt;
I thought to capture this also in a field with a regex, you know like an optional field? but it didn't really work. your suggestion did infact helped in my case but what if it was not the case and i had "(null)","none","void" not just "(null)" then?&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2013 19:28:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Unable-to-extract-fields-through-regular-expression-and/m-p/146768#M41011</guid>
      <dc:creator>luv</dc:creator>
      <dc:date>2013-11-18T19:28:54Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to extract fields through regular expression and combining them into a single field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Unable-to-extract-fields-through-regular-expression-and/m-p/146769#M41012</link>
      <description>&lt;P&gt;(?P) is for python friendly regular expression (nothing python specific here), I'm used to write my regex like that. &lt;/P&gt;

&lt;P&gt;I updated the answer to capture field5 as it is, so we don't have to do concatenation of fields and in case fields not available, it'll take whatever is available.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2013 20:15:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Unable-to-extract-fields-through-regular-expression-and/m-p/146769#M41012</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2013-11-18T20:15:01Z</dc:date>
    </item>
  </channel>
</rss>

