<?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: Is there a way to be more efficient in writing this query - Regex/Wildcard/Substitution question in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-be-more-efficient-in-writing-this-query-Regex/m-p/747900#M241913</link>
    <description>&lt;P&gt;There may be more than one way to do that using regular expressions.&amp;nbsp; Here's one of them.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex field=API_RESOURCE "\/v(?&amp;lt;API_RESOURCE&amp;gt;\d+)"&lt;/LI-CODE&gt;&lt;P&gt;Use this command line in place of the existing &lt;FONT face="courier new,courier"&gt;eval&lt;/FONT&gt;.&lt;/P&gt;</description>
    <pubDate>Thu, 12 Jun 2025 18:22:34 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2025-06-12T18:22:34Z</dc:date>
    <item>
      <title>Is there a way to be more efficient in writing this query - Regex/Wildcard/Substitution question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-be-more-efficient-in-writing-this-query-Regex/m-p/747898#M241912</link>
      <description>&lt;P&gt;I have the below query I've written - I am used to SQL, SPL is still new to me. I feel like there has to be some way to make this shorter/more efficient - i.e:&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data:&lt;/P&gt;&lt;P&gt;API_RESOURCE="&lt;SPAN class=""&gt;/v63.0/gobbledygook&lt;/SPAN&gt;&lt;SPAN&gt;/&lt;/SPAN&gt;&lt;SPAN class=""&gt;unrequitededits_somename_request&lt;/SPAN&gt;"&lt;/P&gt;&lt;P&gt;API_RESOURCE="&lt;SPAN class=""&gt;/v62.0/gobbledygook&lt;/SPAN&gt;&lt;SPAN&gt;/&lt;/SPAN&gt;&lt;SPAN class=""&gt;unrequitededits_somename_response&lt;/SPAN&gt;"&lt;/P&gt;&lt;P&gt;API_RESOURCE="&lt;SPAN class=""&gt;/v61.0/gobbledygook&lt;/SPAN&gt;&lt;SPAN&gt;/&lt;/SPAN&gt;&lt;SPAN class=""&gt;unrequitededits_somename_update&lt;/SPAN&gt;"&lt;/P&gt;&lt;P&gt;API_RESOURCE="&lt;SPAN class=""&gt;/v63.0/gobbledygook&lt;/SPAN&gt;&lt;SPAN&gt;/&lt;/SPAN&gt;&lt;SPAN class=""&gt;unrequitededits_somename_delete&lt;/SPAN&gt;"&lt;/P&gt;&lt;P&gt;API_RESOURCE="&lt;SPAN class=""&gt;/v61.0/gobbledygook&lt;/SPAN&gt;&lt;SPAN&gt;/&lt;/SPAN&gt;&lt;SPAN class=""&gt;unrequitededits_somename_delete&lt;/SPAN&gt;"&lt;/P&gt;&lt;P&gt;API_RESOURCE="&lt;SPAN class=""&gt;/v62.0/gobbledygook&lt;/SPAN&gt;&lt;SPAN&gt;/&lt;/SPAN&gt;&lt;SPAN class=""&gt;unrequitededits_somename_update&lt;/SPAN&gt;"&lt;/P&gt;&lt;P&gt;API_RESOURCE="&lt;SPAN class=""&gt;/v61.0/gobbledygook&lt;/SPAN&gt;&lt;SPAN&gt;/&lt;/SPAN&gt;&lt;SPAN class=""&gt;URI_PATH_batch_updates&lt;/SPAN&gt;"&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Original query:&lt;BR /&gt;index="some_index"&lt;BR /&gt;&lt;BR /&gt;API_RESOURCE!=""&lt;/P&gt;&lt;P&gt;| eval API_RESOURCE=case(&lt;/P&gt;&lt;P&gt;LIKE(API_RESOURCE,"%63%"),"/v63",&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;LIKE(API_RESOURCE,"%62%"),"/v62",&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;LIKE(API_RESOURCE,"%61%"),"/v61",1==1, API_RESOURCE)&lt;BR /&gt;&lt;BR /&gt;|stats count by API_RESOURCE&lt;/P&gt;&lt;P&gt;Desired query:&lt;BR /&gt;&lt;BR /&gt;index="some_index"&lt;/P&gt;&lt;P&gt;API_RESOURCE!=""&lt;/P&gt;&lt;P&gt;| eval API_RESOURCE=case(LIKE(API_RESOURCE,"%6\d%"),"/v6\d",1==1, API_RESOURCE)&lt;/P&gt;&lt;P&gt;|stats count by API_RESOURCE&lt;/P&gt;&lt;P&gt;Where the outcome would be the three versions being counted as grouped within their own version (so, v/63 = 2, v/62 = 2, v/61= 2&lt;BR /&gt;&lt;BR /&gt;Every time I run the 'desired query' it completely ignores the wildcard/variable in both the search and replace part of the case statement.&lt;BR /&gt;&lt;BR /&gt;Any help would be appreciated, as there are at least 64 current versions, and every time a new one is developed it gets the next highest version number&lt;BR /&gt;&lt;BR /&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jun 2025 17:59:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-be-more-efficient-in-writing-this-query-Regex/m-p/747898#M241912</guid>
      <dc:creator>ripvw32</dc:creator>
      <dc:date>2025-06-12T17:59:59Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to be more efficient in writing this query - Regex/Wildcard/Substitution question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-be-more-efficient-in-writing-this-query-Regex/m-p/747900#M241913</link>
      <description>&lt;P&gt;There may be more than one way to do that using regular expressions.&amp;nbsp; Here's one of them.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex field=API_RESOURCE "\/v(?&amp;lt;API_RESOURCE&amp;gt;\d+)"&lt;/LI-CODE&gt;&lt;P&gt;Use this command line in place of the existing &lt;FONT face="courier new,courier"&gt;eval&lt;/FONT&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jun 2025 18:22:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-be-more-efficient-in-writing-this-query-Regex/m-p/747900#M241913</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2025-06-12T18:22:34Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to be more efficient in writing this query - Regex/Wildcard/Substitution question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-be-more-efficient-in-writing-this-query-Regex/m-p/747901#M241914</link>
      <description>&lt;P&gt;Thank you so much for the response!!!&lt;BR /&gt;&lt;BR /&gt;That didn't seem to do the trick -&amp;nbsp; Still seeing entries like this in my table&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/v63.0/gobbldygook/unrequietededit/describe&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;Also, I am seeing that API_RESOURCE also contains singular words, like "Update", "Delete", "Login" etc, with no v/2digitnumber (didn't see them before as the data is several dozen pages long, at 100 rows per page)&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jun 2025 18:43:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-be-more-efficient-in-writing-this-query-Regex/m-p/747901#M241914</guid>
      <dc:creator>ripvw32</dc:creator>
      <dc:date>2025-06-12T18:43:16Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to be more efficient in writing this query - Regex/Wildcard/Substitution question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-be-more-efficient-in-writing-this-query-Regex/m-p/747903#M241915</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/310908"&gt;@ripvw32&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Use rex with a regular expression to extract or normalize the version segment efficiently, instead of using multiple LIKE or case statements.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;For exxample:&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;| makeresults
| eval API_RESOURCE="/v63.0/gobbledygook/unrequitededits_somename_request"
| append [| makeresults | eval API_RESOURCE="/v62.0/gobbledygook/unrequitededits_somename_response"]
| append [| makeresults | eval API_RESOURCE="/v61.0/gobbledygook/unrequitededits_somename_update"]
| append [| makeresults | eval API_RESOURCE="/v63.0/gobbledygook/unrequitededits_somename_delete"]
| append [| makeresults | eval API_RESOURCE="/v61.0/gobbledygook/unrequitededits_somename_delete"]
| append [| makeresults | eval API_RESOURCE="/v62.0/gobbledygook/unrequitededits_somename_update"]
| append [| makeresults | eval API_RESOURCE="/v61.0/gobbledygook/URI_PATH_batch_updates"]
| rex field=API_RESOURCE "^/(?&amp;lt;version&amp;gt;v\d+)\."
| stats count by version&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="livehybrid_0-1749756115496.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/39363i197A21E8EFB1F7BF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="livehybrid_0-1749756115496.png" alt="livehybrid_0-1749756115496.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;rex extracts the version (e.g., v63, v62, v61) from the start of API_RESOURCE. - stats count by version groups and counts by the extracted version. - This approach is scalable and requires no manual updates for new versions.&lt;/P&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>Thu, 12 Jun 2025 19:26:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-be-more-efficient-in-writing-this-query-Regex/m-p/747903#M241915</guid>
      <dc:creator>livehybrid</dc:creator>
      <dc:date>2025-06-12T19:26:45Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to be more efficient in writing this query - Regex/Wildcard/Substitution question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-be-more-efficient-in-writing-this-query-Regex/m-p/747904#M241916</link>
      <description>&lt;P&gt;And if you want the full version number after . then try:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex field=API_RESOURCE "^/(?&amp;lt;version&amp;gt;v[\d\.]+)\/"&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>Thu, 12 Jun 2025 19:23:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-be-more-efficient-in-writing-this-query-Regex/m-p/747904#M241916</guid>
      <dc:creator>livehybrid</dc:creator>
      <dc:date>2025-06-12T19:23:26Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to be more efficient in writing this query - Regex/Wildcard/Substitution question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-be-more-efficient-in-writing-this-query-Regex/m-p/747920#M241919</link>
      <description>&lt;P&gt;It shows that you think like SQL. &amp;nbsp;The API version in your examples is the easiest to extract in Splunk. (In fact, in any modern language other than SQL.) And using case function is about the most complicated method. &amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/170906"&gt;@livehybrid&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;&amp;nbsp;suggested regex. &amp;nbsp;There is an even simpler and perhaps cheaper method:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval version = mvindex(split(API_RESOURCE, "/"), 1)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jun 2025 05:19:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-be-more-efficient-in-writing-this-query-Regex/m-p/747920#M241919</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2025-06-13T05:19:11Z</dc:date>
    </item>
  </channel>
</rss>

