<?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: Grouping by name in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Grouping-by-name/m-p/343072#M160750</link>
    <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval x="183512 217654 217655 217656 217657 224808 263806 263807 263808 263809 263810 263811 279992 279996 314724" 
| makemv x 
| mvexpand x 

| rename COMMENT AS "Everything above creates test event data; everything below is your solution"

| rex mode=sed field=x "s/(26380[6-9]|26381[0-1])$/group1/g s/^\d+$/group2/g" 
| stats count by x
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 12 Jun 2017 02:40:44 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2017-06-12T02:40:44Z</dc:date>
    <item>
      <title>Grouping by name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Grouping-by-name/m-p/343070#M160748</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
In my search results i have numbers like this and i would like to group them by group1 and group2.&lt;BR /&gt;
Where group1 =263806,263807,263808,263809,263810,263811&lt;BR /&gt;
and rest numbers should be group2&lt;/P&gt;

&lt;P&gt;So i have used the below expression, i see group1 but group2 is not working properly&lt;/P&gt;

&lt;P&gt;| rex mode=sed field=x "s/(26380[6-9]|26381[0-1])$/group1/g" | rex mode=sed field=x "s/([^(26380[6-9]]$|[^26381[0-1]]$)/group2/g" | stats count by  x&lt;/P&gt;

&lt;P&gt;183512&lt;BR /&gt;&lt;BR /&gt;
217654&lt;BR /&gt;&lt;BR /&gt;
217655&lt;BR /&gt;&lt;BR /&gt;
217656&lt;BR /&gt;&lt;BR /&gt;
217657&lt;BR /&gt;&lt;BR /&gt;
224808&lt;BR /&gt;&lt;BR /&gt;
263806&lt;BR /&gt;&lt;BR /&gt;
263807&lt;BR /&gt;&lt;BR /&gt;
263808&lt;BR /&gt;&lt;BR /&gt;
263809&lt;BR /&gt;&lt;BR /&gt;
263810&lt;BR /&gt;&lt;BR /&gt;
263811&lt;BR /&gt;&lt;BR /&gt;
279992&lt;BR /&gt;&lt;BR /&gt;
279996&lt;BR /&gt;
314724  &lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2017 00:03:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Grouping-by-name/m-p/343070#M160748</guid>
      <dc:creator>xvxt006</dc:creator>
      <dc:date>2017-06-11T00:03:40Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping by name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Grouping-by-name/m-p/343071#M160749</link>
      <description>&lt;P&gt;You'll need to specify the boundary of your numeric string.  Assuming the strategy is right aggressive, you answer should look like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex mode=sed field=x "s/(26380[6-9]|26381[0-1])$/group1/g"
| rex mode=sed field=x "s/\d+/group2/g"
| stats count by x
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The errors in your second expression take some nuance to explain, but you do not need any complexity.  If your expression for the first group is correct, just use the side effect of mode sed: the second expression will never see numbers in the first group.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2017 00:36:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Grouping-by-name/m-p/343071#M160749</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2017-06-11T00:36:54Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping by name</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Grouping-by-name/m-p/343072#M160750</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval x="183512 217654 217655 217656 217657 224808 263806 263807 263808 263809 263810 263811 279992 279996 314724" 
| makemv x 
| mvexpand x 

| rename COMMENT AS "Everything above creates test event data; everything below is your solution"

| rex mode=sed field=x "s/(26380[6-9]|26381[0-1])$/group1/g s/^\d+$/group2/g" 
| stats count by x
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Jun 2017 02:40:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Grouping-by-name/m-p/343072#M160750</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-06-12T02:40:44Z</dc:date>
    </item>
  </channel>
</rss>

