<?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 regular Expression extration in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/regular-Expression-extration/m-p/290877#M87898</link>
    <description>&lt;P&gt;I want to do something like this, referer_domain is the field i want to extract to create a new field. I want to rex the google as one field and bing as another field, Say example google as Test and bing as Test1&lt;/P&gt;

&lt;P&gt;referer_domain&lt;BR /&gt;
&lt;A href="http://www.bing.com"&gt;http://www.bing.com&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www.buttercupgames.com"&gt;http://www.buttercupgames.com&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www.google.com"&gt;http://www.google.com&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www.yahoo.com"&gt;http://www.yahoo.com&lt;/A&gt;&lt;BR /&gt;
&lt;A href="https://www.google.com"&gt;https://www.google.com&lt;/A&gt;&lt;BR /&gt;
&lt;A href="https://www.bing.com"&gt;https://www.bing.com&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I did something like this, which is not working out,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main sourcetype=access_combined_wcookie  
| rex field=referer_domain "(?&amp;lt;Test&amp;gt;google)"  
| rex field=referer_domain "(?&amp;lt;Test1&amp;gt;bing)"  
| stats count by Test Test1 host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I can see single extraction is working fine as expected(the below query), but not the double one. Is it not allowed in splunk or am i missing out any syntax?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main sourcetype=access_combined_wcookie 
| rex field=referer_domain "(?&amp;lt;Test&amp;gt;google)" 
| stats count by Test Test1 host
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 06 Jul 2017 05:10:51 GMT</pubDate>
    <dc:creator>Kwip</dc:creator>
    <dc:date>2017-07-06T05:10:51Z</dc:date>
    <item>
      <title>regular Expression extration</title>
      <link>https://community.splunk.com/t5/Splunk-Search/regular-Expression-extration/m-p/290877#M87898</link>
      <description>&lt;P&gt;I want to do something like this, referer_domain is the field i want to extract to create a new field. I want to rex the google as one field and bing as another field, Say example google as Test and bing as Test1&lt;/P&gt;

&lt;P&gt;referer_domain&lt;BR /&gt;
&lt;A href="http://www.bing.com"&gt;http://www.bing.com&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www.buttercupgames.com"&gt;http://www.buttercupgames.com&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www.google.com"&gt;http://www.google.com&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www.yahoo.com"&gt;http://www.yahoo.com&lt;/A&gt;&lt;BR /&gt;
&lt;A href="https://www.google.com"&gt;https://www.google.com&lt;/A&gt;&lt;BR /&gt;
&lt;A href="https://www.bing.com"&gt;https://www.bing.com&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I did something like this, which is not working out,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main sourcetype=access_combined_wcookie  
| rex field=referer_domain "(?&amp;lt;Test&amp;gt;google)"  
| rex field=referer_domain "(?&amp;lt;Test1&amp;gt;bing)"  
| stats count by Test Test1 host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I can see single extraction is working fine as expected(the below query), but not the double one. Is it not allowed in splunk or am i missing out any syntax?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main sourcetype=access_combined_wcookie 
| rex field=referer_domain "(?&amp;lt;Test&amp;gt;google)" 
| stats count by Test Test1 host
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Jul 2017 05:10:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/regular-Expression-extration/m-p/290877#M87898</guid>
      <dc:creator>Kwip</dc:creator>
      <dc:date>2017-07-06T05:10:51Z</dc:date>
    </item>
    <item>
      <title>Re: regular Expression extration</title>
      <link>https://community.splunk.com/t5/Splunk-Search/regular-Expression-extration/m-p/290878#M87899</link>
      <description>&lt;P&gt;try this &lt;BR /&gt;
index=main sourcetype=access_combined_wcookie  | rex field=referer_domain "(?&amp;amp;lttest1&amp;amp;gtgoogle)|(?&amp;amp;lttest2&amp;amp;gtbing)  | stats count by test1 test2 host&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:43:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/regular-Expression-extration/m-p/290878#M87899</guid>
      <dc:creator>sbbadri</dc:creator>
      <dc:date>2020-09-29T14:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: regular Expression extration</title>
      <link>https://community.splunk.com/t5/Splunk-Search/regular-Expression-extration/m-p/290879#M87900</link>
      <description>&lt;P&gt;The problem isn't the extraction, its the &lt;CODE&gt;stats&lt;/CODE&gt;.  &lt;CODE&gt;stats&lt;/CODE&gt; will ignore all records that have nulls in any of the &lt;CODE&gt;by&lt;/CODE&gt; fields.  &lt;/P&gt;

&lt;P&gt;To make that work, you would have to add a &lt;CODE&gt;fillnull&lt;/CODE&gt; command before stats.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| fillnull value="" Test Test1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, this is cleaner...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=main sourcetype=access_combined_wcookie  
| rex field=referer_domain "(?i)(?&amp;lt;Test&amp;gt;Google|Bing)"  
| fillnull value="Other" Test
| stats count by Test host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;Note - I made the test case-insensitive &lt;CODE&gt;(?i)&lt;/CODE&gt; and capitalized the search engine names to make it pretty.  Isn't that just &lt;EM&gt;precious&lt;/EM&gt;?&lt;/P&gt;

&lt;P&gt;Edited to mark keywords as code.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2017 15:42:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/regular-Expression-extration/m-p/290879#M87900</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-07-06T15:42:29Z</dc:date>
    </item>
    <item>
      <title>Re: regular Expression extration</title>
      <link>https://community.splunk.com/t5/Splunk-Search/regular-Expression-extration/m-p/290880#M87901</link>
      <description>&lt;P&gt;you are always hitting the target with cent percent accuracy @DalJeanis. Below is what my expectation. Thank you.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main sourcetype=access_combined_wcookie  
 | rex field=referer_domain "(?&amp;lt;Test&amp;gt;google)"  
 | rex field=referer_domain "(?&amp;lt;Test1&amp;gt;bing)"  
| fillnull value="-" Test Test1
 | stats count by Test Test1 host
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Jul 2017 17:15:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/regular-Expression-extration/m-p/290880#M87901</guid>
      <dc:creator>Kwip</dc:creator>
      <dc:date>2017-07-06T17:15:59Z</dc:date>
    </item>
    <item>
      <title>Re: regular Expression extration</title>
      <link>https://community.splunk.com/t5/Splunk-Search/regular-Expression-extration/m-p/290881#M87902</link>
      <description>&lt;P&gt;Thank you for valuable comment @sbbadri. below is the one i am looking for,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main sourcetype=access_combined_wcookie  
 | rex field=referer_domain "(?&amp;lt;Test&amp;gt;google)|(?&amp;lt;Test1&amp;gt;bing)"  
| fillnull value="-" Test Test1
 | stats count by Test Test1 host
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Jul 2017 17:19:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/regular-Expression-extration/m-p/290881#M87902</guid>
      <dc:creator>Kwip</dc:creator>
      <dc:date>2017-07-06T17:19:52Z</dc:date>
    </item>
  </channel>
</rss>

