{"id":69889,"date":"2023-01-23T13:23:14","date_gmt":"2023-01-23T13:23:14","guid":{"rendered":"https:\/\/merikebi.warrenmyers.com\/?p=69889"},"modified":"2023-01-23T13:23:14","modified_gmt":"2023-01-23T13:23:14","slug":"answer-by-warren-for-regex-count-capture-group-members","status":"publish","type":"post","link":"https:\/\/merikebi.warrenmyers.com\/?p=69889","title":{"rendered":"Answer by warren for Regex count capture group members"},"content":{"rendered":"<p>In Splunk, to capture multiple matches from a single event, you need to add <code>max_match=0<\/code> to your <code>rex<\/code>, per <a href=\"https:\/\/docs.splunk.com\/Documentation\/Splunk\/latest\/SearchReference\/rex\" rel=\"nofollow noreferrer\">docs.Splunk<\/a><\/p>\n<p>But to get them then <em>separated<\/em> into a singlevalue field from the [potential] multivalue field <code>job_ids<\/code> that you made, you need to <a href=\"https:\/\/docs.splunk.com\/Documentation\/Splunk\/latest\/SearchReference\/mvexpand\" rel=\"nofollow noreferrer\"><code>mvxepand<\/code><\/a> or similar<\/p>\n<p>So this should get you closer:<\/p>\n<pre><code>| rex field=message max_match=0 &quot;\\&quot;(?&lt;job_id&gt;(?:\\w+-\\w+-\\w+-\\w+-\\w+)+),?\\&quot;&quot; \n| mvexpand job_id\n| stats dc(job_id)\n<\/code><\/pre>\n<p>I also changed from <code>count<\/code> to <code>dc<\/code>, as it <em>seems<\/em> you&#8217;re looking for a unique count of job IDs, and not just a count of how many in total you&#8217;ve seen<\/p>\n<p>from User warren &#8211; Stack Overflow https:\/\/stackoverflow.com\/questions\/75188876\/regex-count-capture-group-members\/75210114#75210114<br \/>\nvia <a href=\"https:\/\/ifttt.com\/?ref=da&#038;site=wordpress\">IFTTT<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Splunk, to capture multiple matches from a single event, you need to add max_match=0 to your rex, per docs.Splunk But to get them then separated into a singlevalue field from the [potential] multivalue field job_ids that you made, you need to mvxepand or similar So this should get you closer: | rex field=message max_match=0 &hellip;<br \/><a href=\"https:\/\/merikebi.warrenmyers.com\/?p=69889\" class=\"more-link pen_button pen_element_default pen_icon_arrow_double\">Continue reading <span class=\"screen-reader-text\">Answer by warren for Regex count capture group members<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[991],"keyring_services":[],"class_list":["post-69889","post","type-post","status-publish","format-standard","hentry","category-blih","tag-stackexchange"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/69889","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=69889"}],"version-history":[{"count":1,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/69889\/revisions"}],"predecessor-version":[{"id":69890,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/69889\/revisions\/69890"}],"wp:attachment":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=69889"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=69889"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=69889"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fkeyring_services&post=69889"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}