<?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 to combine two field extractions into 1 with regex? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-two-field-extractions-into-1-with-regex/m-p/207407#M60478</link>
    <description>&lt;P&gt;Hey, do it like this and let me know if this is what you like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;extract-aaa = ((?&amp;lt;field1Name&amp;gt;[field1NameRegex])(?&amp;lt;field2Name&amp;gt;[field2NameRegex]))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So if this was my data:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;timestamp - datafield1 and datafield2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I might use this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;extract-aaa = (?&amp;lt;field1&amp;gt;(?&amp;lt;=timestamp - ).*(?= and )(?&amp;lt;field2&amp;gt;.*)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 23 Dec 2015 21:53:19 GMT</pubDate>
    <dc:creator>jkat54</dc:creator>
    <dc:date>2015-12-23T21:53:19Z</dc:date>
    <item>
      <title>How to combine two field extractions into 1 with regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-two-field-extractions-into-1-with-regex/m-p/207402#M60473</link>
      <description>&lt;P&gt;I read in the best practices that if possible, combine two field extractions in to 1. This will improve the efficiency of the system.&lt;/P&gt;

&lt;P&gt;But when I tried implementing it, it's not giving satisfactory results for all scenarios.&lt;/P&gt;

&lt;P&gt;eg. When the 1st field is blank or space, it's not extracting the 2nd field consistently.&lt;/P&gt;

&lt;P&gt;Has anyone else also faced this issue?&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 22 Dec 2015 22:09:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-two-field-extractions-into-1-with-regex/m-p/207402#M60473</guid>
      <dc:creator>kamal_jagga</dc:creator>
      <dc:date>2015-12-22T22:09:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two field extractions into 1 with regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-two-field-extractions-into-1-with-regex/m-p/207403#M60474</link>
      <description>&lt;P&gt;Hi @kamal_jagga&lt;/P&gt;

&lt;P&gt;I think it'll be best if you include sample data and the regular expression(s) you've tried already for other users to best help you here.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Dec 2015 22:26:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-two-field-extractions-into-1-with-regex/m-p/207403#M60474</guid>
      <dc:creator>ppablo</dc:creator>
      <dc:date>2015-12-22T22:26:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two field extractions into 1 with regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-two-field-extractions-into-1-with-regex/m-p/207404#M60475</link>
      <description>&lt;P&gt;Following are my 2 Field extractions:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;100_cricket : EXTRACT-runs_1     ^.{23}.{23}35.{121}(?P&amp;lt;runs_1&amp;gt;.{1})
100_cricket : EXTRACT-runs_2     ^.{23}.{23}35.{123}(?P&amp;lt;runs_2&amp;gt;.{1})
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would like to combine them to improve efficiency.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;100_cricket : EXTRACT-runs_1,runs_2      ^.{23}.{23}35.{123}(?P&amp;lt;runs_1&amp;gt;.{1})?(?P&amp;lt;runs_2&amp;gt;.{1})
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But this regex doesn't work if 1st field is blank or junk values.&lt;/P&gt;

&lt;P&gt;Kindly advise.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Dec 2015 22:51:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-two-field-extractions-into-1-with-regex/m-p/207404#M60475</guid>
      <dc:creator>kamal_jagga</dc:creator>
      <dc:date>2015-12-22T22:51:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two field extractions into 1 with regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-two-field-extractions-into-1-with-regex/m-p/207405#M60476</link>
      <description>&lt;P&gt;i faced the same issue when combining multiple field extractions under one rex. Though i had a work around to split them into multiple rex, I would like to understand if this is a limitation&lt;/P&gt;</description>
      <pubDate>Wed, 23 Dec 2015 00:11:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-two-field-extractions-into-1-with-regex/m-p/207405#M60476</guid>
      <dc:creator>Murali2888</dc:creator>
      <dc:date>2015-12-23T00:11:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two field extractions into 1 with regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-two-field-extractions-into-1-with-regex/m-p/207406#M60477</link>
      <description>&lt;P&gt;The regular expression syntax can get a bit complicated when extracting multiple fields under one rex, but it does work.  I suggest using a tool like regex101.com to test with your regular expressions to get it right.  I find that they usually happily transfer into Splunk once you've got the syntax right.&lt;/P&gt;

&lt;P&gt;Here's a run anywhere splunk example that extracts multiple fields using one rex.  Note the nesting of fields extractions.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|stats count as foo |eval foo = " la de dah de da" |rex field=foo "^(?: *)(?P&amp;lt;all&amp;gt;(?P&amp;lt;first&amp;gt;[^\s]+) de (?P&amp;lt;middle&amp;gt;[^\s]+) de (?P&amp;lt;last&amp;gt;.+).*)$"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I suggest going to regex101 (or some other regex tool) and playing around.  Here's a link to the example above: &lt;A href="https://regex101.com/r/iU2zD0/1"&gt;https://regex101.com/r/iU2zD0/1&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Dec 2015 21:23:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-two-field-extractions-into-1-with-regex/m-p/207406#M60477</guid>
      <dc:creator>gcato</dc:creator>
      <dc:date>2015-12-23T21:23:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two field extractions into 1 with regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-two-field-extractions-into-1-with-regex/m-p/207407#M60478</link>
      <description>&lt;P&gt;Hey, do it like this and let me know if this is what you like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;extract-aaa = ((?&amp;lt;field1Name&amp;gt;[field1NameRegex])(?&amp;lt;field2Name&amp;gt;[field2NameRegex]))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So if this was my data:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;timestamp - datafield1 and datafield2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I might use this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;extract-aaa = (?&amp;lt;field1&amp;gt;(?&amp;lt;=timestamp - ).*(?= and )(?&amp;lt;field2&amp;gt;.*)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Dec 2015 21:53:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-two-field-extractions-into-1-with-regex/m-p/207407#M60478</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2015-12-23T21:53:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two field extractions into 1 with regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-two-field-extractions-into-1-with-regex/m-p/207408#M60479</link>
      <description>&lt;P&gt;my regex doesnt work with my data sample by the way but i'm thinking you might get the point if you know regex well enough.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Dec 2015 21:57:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-two-field-extractions-into-1-with-regex/m-p/207408#M60479</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2015-12-23T21:57:30Z</dc:date>
    </item>
  </channel>
</rss>

