<?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 merge multiple rex commands in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/how-to-merge-multiple-rex-commands/m-p/104321#M27013</link>
    <description>&lt;P&gt;Why not combine them into one rex statement with multiple ability to match multiple times.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;BR /&gt;
rex field="Location"(?&lt;NLOC&gt;(?im)"(delhi|mumbai|kol)") &lt;BR /&gt;
&lt;/NLOC&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 26 Oct 2012 21:58:14 GMT</pubDate>
    <dc:creator>bmacias84</dc:creator>
    <dc:date>2012-10-26T21:58:14Z</dc:date>
    <item>
      <title>how to merge multiple rex commands</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-merge-multiple-rex-commands/m-p/104319#M27011</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have a query as follows :&lt;/P&gt;

&lt;P&gt;index="maa" |rex field="Location" (?&lt;ONE&gt;(?i)"delhi") | eval ONE=lower(ONE) |stats count(ONE) by ONE | append [search index="maa" |rex field="Location" | (?&lt;ONE&gt;(?i)"kol") | eval ONE=lower(ONE) |stats count(ONE) by ONE ] | append [ search index="maa" | rex field="Location" (?&lt;ONE&gt;(?i)"mumbai") | eval ONE=lower(ONE) |stats count(ONE) by ONE]&lt;/ONE&gt;&lt;/ONE&gt;&lt;/ONE&gt;&lt;/P&gt;

&lt;P&gt;Here, I am using 3 keywords "delhi","kol" and "mumbai" but I have used 3 rex for this..can I merge three into one rex. when I am merging as follows I am getting the correct count for the keywords. Please help&lt;/P&gt;

&lt;P&gt;index "maa" | rex field="Locaion" (?&lt;ONE&gt;(?i)"delhi|kol|mumbai") | eval ONE=lower(ONE) |stats count(ONE) by ONE&lt;/ONE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Oct 2012 19:36:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-merge-multiple-rex-commands/m-p/104319#M27011</guid>
      <dc:creator>abhayneilam</dc:creator>
      <dc:date>2012-10-26T19:36:08Z</dc:date>
    </item>
    <item>
      <title>Re: how to merge multiple rex commands</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-merge-multiple-rex-commands/m-p/104320#M27012</link>
      <description>&lt;P&gt;Hi  Abhay..&lt;/P&gt;

&lt;P&gt;You can create field aliases for your thress rex fields as location and then you can use the stats count by location like this .&lt;/P&gt;

&lt;P&gt;rex field="Location" (?&lt;DELHI&gt;(?i)"delhi") &lt;BR /&gt;
rex field="Location" | (?&lt;KOL&gt;(?i)"kol") &lt;BR /&gt;
rex field="Location" (?&lt;MUMBAI&gt;(?i)"mumbai") &lt;/MUMBAI&gt;&lt;/KOL&gt;&lt;/DELHI&gt;&lt;/P&gt;

&lt;P&gt;Now go to Field Aliases and create a common alias for these three fields i.e say location .&lt;/P&gt;

&lt;P&gt;Then use your query like this..&lt;/P&gt;

&lt;P&gt;index="maa" | stats count by location &lt;/P&gt;

&lt;P&gt;Would you give the desired results..&lt;/P&gt;</description>
      <pubDate>Fri, 26 Oct 2012 21:05:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-merge-multiple-rex-commands/m-p/104320#M27012</guid>
      <dc:creator>rakesh_498115</dc:creator>
      <dc:date>2012-10-26T21:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: how to merge multiple rex commands</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-merge-multiple-rex-commands/m-p/104321#M27013</link>
      <description>&lt;P&gt;Why not combine them into one rex statement with multiple ability to match multiple times.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;BR /&gt;
rex field="Location"(?&lt;NLOC&gt;(?im)"(delhi|mumbai|kol)") &lt;BR /&gt;
&lt;/NLOC&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Oct 2012 21:58:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-merge-multiple-rex-commands/m-p/104321#M27013</guid>
      <dc:creator>bmacias84</dc:creator>
      <dc:date>2012-10-26T21:58:14Z</dc:date>
    </item>
    <item>
      <title>Re: how to merge multiple rex commands</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-merge-multiple-rex-commands/m-p/104322#M27014</link>
      <description>&lt;P&gt;the problem is, that in the data multiple city occur at the same line:&lt;/P&gt;

&lt;P&gt;abhay|26|koldelhigmumbaiis_delhiood_di&lt;BR /&gt;
murari|30|ranigang&lt;BR /&gt;
abc|32|mumbai is delhi place&lt;BR /&gt;
murari|30|ranigang_kolbabbu is kol&lt;BR /&gt;
murari|30|delHI is not in kolkata&lt;BR /&gt;
mno|100|delhi&lt;BR /&gt;
murari|30|ranig&lt;BR /&gt;
xyz|100|delhi&lt;/P&gt;

&lt;P&gt;abhayneilam want to match only ONE city per line, either delhi, kol or mumbai.&lt;BR /&gt;
I cannot create any regex matching this pattern on gskinner....sorry but on the other hand I'm no regex expert after all &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:42:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-merge-multiple-rex-commands/m-p/104322#M27014</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2020-09-28T12:42:23Z</dc:date>
    </item>
  </channel>
</rss>

