<?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: Need a query to find count of substring within string in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Need-a-query-to-find-count-of-substring-within-string/m-p/747762#M241876</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/310833"&gt;@caschmid&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would something like this work for you? This assumes you know the string you want count, is that right?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="livehybrid_0-1749586546263.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/39341i4BB10ADF878406D5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="livehybrid_0-1749586546263.png" alt="livehybrid_0-1749586546263.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex max_match=100 field=_raw "(?&amp;lt;extract&amp;gt;\[string\])"
| stats count by extract&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":glowing_star:"&gt;🌟&lt;/span&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Did this answer help you?&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;If so, please consider:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Adding karma to show it was useful&lt;/LI&gt;&lt;LI&gt;Marking it as the solution if it resolved your issue&lt;/LI&gt;&lt;LI&gt;Commenting if you need any clarification&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Your feedback encourages the volunteers in this community to continue contributing&lt;/P&gt;</description>
    <pubDate>Tue, 10 Jun 2025 20:17:22 GMT</pubDate>
    <dc:creator>livehybrid</dc:creator>
    <dc:date>2025-06-10T20:17:22Z</dc:date>
    <item>
      <title>Need a query to find count of substring within string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-a-query-to-find-count-of-substring-within-string/m-p/747754#M241872</link>
      <description>&lt;P&gt;I need a query that will tell me the count of a substring within a string like this ...&lt;/P&gt;&lt;P&gt;"This is my [string]" and I need find the word and count of [string]. "This is my" is always the same but [string] is dynamic and can be many things, such as apple, banana etc. I need tabular data returned to look like&amp;nbsp;&lt;/P&gt;&lt;P&gt;Word&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Count&lt;/P&gt;&lt;P&gt;apple&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;/P&gt;&lt;P&gt;I tried this but doesnt seem to working&amp;nbsp;&lt;/P&gt;&lt;P&gt;rex field=_raw ".*This is my (?&amp;lt;string&amp;gt;\d+).*" | stats count by string&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jun 2025 17:03:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-a-query-to-find-count-of-substring-within-string/m-p/747754#M241872</guid>
      <dc:creator>caschmid</dc:creator>
      <dc:date>2025-06-10T17:03:02Z</dc:date>
    </item>
    <item>
      <title>Re: Need a query to find count of substring within string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-a-query-to-find-count-of-substring-within-string/m-p/747759#M241875</link>
      <description>&lt;P&gt;Use &lt;A href="https://regex101.com" target="_blank"&gt;https://regex101.com&lt;/A&gt; to verify your regexes.&lt;/P&gt;&lt;P&gt;In this case it won't work for "string" not being a number because \d+ means a sequence of digits. Depending on how precise you want to be with this match, you might want \S+ or some other variation.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jun 2025 18:16:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-a-query-to-find-count-of-substring-within-string/m-p/747759#M241875</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2025-06-10T18:16:54Z</dc:date>
    </item>
    <item>
      <title>Re: Need a query to find count of substring within string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-a-query-to-find-count-of-substring-within-string/m-p/747762#M241876</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/310833"&gt;@caschmid&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would something like this work for you? This assumes you know the string you want count, is that right?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="livehybrid_0-1749586546263.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/39341i4BB10ADF878406D5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="livehybrid_0-1749586546263.png" alt="livehybrid_0-1749586546263.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex max_match=100 field=_raw "(?&amp;lt;extract&amp;gt;\[string\])"
| stats count by extract&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":glowing_star:"&gt;🌟&lt;/span&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Did this answer help you?&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;If so, please consider:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Adding karma to show it was useful&lt;/LI&gt;&lt;LI&gt;Marking it as the solution if it resolved your issue&lt;/LI&gt;&lt;LI&gt;Commenting if you need any clarification&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Your feedback encourages the volunteers in this community to continue contributing&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jun 2025 20:17:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-a-query-to-find-count-of-substring-within-string/m-p/747762#M241876</guid>
      <dc:creator>livehybrid</dc:creator>
      <dc:date>2025-06-10T20:17:22Z</dc:date>
    </item>
    <item>
      <title>Re: Need a query to find count of substring within string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-a-query-to-find-count-of-substring-within-string/m-p/747768#M241877</link>
      <description>&lt;P&gt;In addition to the other comments, you don't need the .* at the start and end of the regex&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jun 2025 22:35:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-a-query-to-find-count-of-substring-within-string/m-p/747768#M241877</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2025-06-10T22:35:42Z</dc:date>
    </item>
    <item>
      <title>Re: Need a query to find count of substring within string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-a-query-to-find-count-of-substring-within-string/m-p/747769#M241878</link>
      <description>&lt;P&gt;Two problems with your regex.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;FONT face="courier new,courier"&gt;\d&lt;/FONT&gt; represents a digit 0-9. &amp;nbsp;Unless your "string" only includes digits, &lt;FONT face="courier new,courier"&gt;\d+&lt;/FONT&gt; will not match.&lt;/LI&gt;&lt;LI&gt;As&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/170906"&gt;@livehybrid&lt;/a&gt;&amp;nbsp;notes, your original string includes a pair of square brackets.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;A usable code to extract "apple" from&amp;nbsp;&lt;SPAN&gt;"This is my [apple]" would be&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex "This is my \[(?&amp;lt;string&amp;gt;[^\]]+)\]"
| stats count by string &lt;/LI-CODE&gt;&lt;P&gt;Note:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;_raw is the default field for rex command.&lt;/LI&gt;&lt;LI&gt;&lt;FONT face="courier new,courier"&gt;.*&lt;/FONT&gt; at beginning and end of a regex serves no purpose except adding cost.&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Tue, 10 Jun 2025 22:36:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-a-query-to-find-count-of-substring-within-string/m-p/747769#M241878</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2025-06-10T22:36:19Z</dc:date>
    </item>
    <item>
      <title>Re: Need a query to find count of substring within string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-a-query-to-find-count-of-substring-within-string/m-p/747775#M241882</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/310833"&gt;@caschmid&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;\d+ matches only digits, not any word.&lt;/P&gt;&lt;P&gt;If "This is my" is always constant, you can try below&lt;BR /&gt;rex field=_raw "This is my (?&amp;lt;string&amp;gt;\w+)" | stats count by string&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Prewin&lt;BR /&gt;Splunk Enthusiast | Always happy to help! If this answer helped you, please consider marking it as the solution or giving a kudos/Karma. Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jun 2025 03:50:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-a-query-to-find-count-of-substring-within-string/m-p/747775#M241882</guid>
      <dc:creator>PrewinThomas</dc:creator>
      <dc:date>2025-06-11T03:50:37Z</dc:date>
    </item>
  </channel>
</rss>

