<?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 How to cut data in field and display results as a count? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-cut-data-in-field-and-display-results-as-a-count/m-p/587830#M204722</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I have a field called hostName which contains hosts:&lt;/P&gt;
&lt;P&gt;host1\user1&lt;/P&gt;
&lt;P&gt;host1\user2&lt;/P&gt;
&lt;P&gt;host2\user2&lt;/P&gt;
&lt;P&gt;host3\user3&lt;/P&gt;
&lt;P&gt;And I want to basically do a count of the number of times each host appears:&lt;/P&gt;
&lt;P&gt;so:&lt;/P&gt;
&lt;P&gt;Host1 = 2&lt;/P&gt;
&lt;P&gt;Host2 = 1&lt;/P&gt;
&lt;P&gt;Host3 = 1&lt;/P&gt;
&lt;P&gt;So I want to cut the data after the backslash (\) and display the host part of the data as a count.&lt;/P&gt;
&lt;P&gt;I worked out the regex for this is ".+?\\" on Regex 101 but I am not able to figure it out with the rex field commands&lt;/P&gt;
&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 08 Mar 2022 04:47:27 GMT</pubDate>
    <dc:creator>Yy4pb</dc:creator>
    <dc:date>2022-03-08T04:47:27Z</dc:date>
    <item>
      <title>How to cut data in field and display results as a count?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-cut-data-in-field-and-display-results-as-a-count/m-p/587830#M204722</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I have a field called hostName which contains hosts:&lt;/P&gt;
&lt;P&gt;host1\user1&lt;/P&gt;
&lt;P&gt;host1\user2&lt;/P&gt;
&lt;P&gt;host2\user2&lt;/P&gt;
&lt;P&gt;host3\user3&lt;/P&gt;
&lt;P&gt;And I want to basically do a count of the number of times each host appears:&lt;/P&gt;
&lt;P&gt;so:&lt;/P&gt;
&lt;P&gt;Host1 = 2&lt;/P&gt;
&lt;P&gt;Host2 = 1&lt;/P&gt;
&lt;P&gt;Host3 = 1&lt;/P&gt;
&lt;P&gt;So I want to cut the data after the backslash (\) and display the host part of the data as a count.&lt;/P&gt;
&lt;P&gt;I worked out the regex for this is ".+?\\" on Regex 101 but I am not able to figure it out with the rex field commands&lt;/P&gt;
&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2022 04:47:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-cut-data-in-field-and-display-results-as-a-count/m-p/587830#M204722</guid>
      <dc:creator>Yy4pb</dc:creator>
      <dc:date>2022-03-08T04:47:27Z</dc:date>
    </item>
    <item>
      <title>Re: Cut data in field and display results as a count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-cut-data-in-field-and-display-results-as-a-count/m-p/587833#M204724</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/243080"&gt;@Yy4pb&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;please try something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex field=your_field "^(?&amp;lt;your_host&amp;gt;[^\\]+)"&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2022 11:22:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-cut-data-in-field-and-display-results-as-a-count/m-p/587833#M204724</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-03-07T11:22:20Z</dc:date>
    </item>
    <item>
      <title>Re: Cut data in field and display results as a count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-cut-data-in-field-and-display-results-as-a-count/m-p/587894#M204742</link>
      <description>&lt;P&gt;EDIT: I had to add more backslashes to the Regex&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex field=your_field "^(?&amp;lt;your_host&amp;gt;[^\\\\]+)"&lt;/LI-CODE&gt;&lt;P&gt;Thanks!!&lt;/P&gt;&lt;P&gt;_________________&lt;/P&gt;&lt;P&gt;However when I run your command I get an error&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Error in 'rex' command: Encountered the following error while compiling the regex '^(?&amp;lt;your_host&amp;gt;[^\]+)': Regex: missing terminating ] for character class.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2022 17:51:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-cut-data-in-field-and-display-results-as-a-count/m-p/587894#M204742</guid>
      <dc:creator>Yy4pb</dc:creator>
      <dc:date>2022-03-07T17:51:46Z</dc:date>
    </item>
    <item>
      <title>Re: Cut data in field and display results as a count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-cut-data-in-field-and-display-results-as-a-count/m-p/587960#M204766</link>
      <description>&lt;P&gt;Hiu&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/243080"&gt;@Yy4pb&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;you used too many backslashes, the last of tem is considered by Splunk as an escape of ], so the condition in the regex isn't closed.&lt;/P&gt;&lt;P&gt;Try using [^\\] or [^\\\].&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2022 08:05:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-cut-data-in-field-and-display-results-as-a-count/m-p/587960#M204766</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-03-08T08:05:49Z</dc:date>
    </item>
  </channel>
</rss>

