{"id":61296,"date":"2022-08-02T12:22:56","date_gmt":"2022-08-02T12:22:56","guid":{"rendered":"https:\/\/merikebi.warrenmyers.com\/?p=61296"},"modified":"2022-08-02T12:22:56","modified_gmt":"2022-08-02T12:22:56","slug":"answer-by-warren-for-regular-expression-to-exclude-uuid-from-capture-group","status":"publish","type":"post","link":"https:\/\/merikebi.warrenmyers.com\/?p=61296","title":{"rendered":"Answer by warren for Regular expression to exclude UUID from capture group"},"content":{"rendered":"<p>Instead of trying to capture everything <a href=\"https:\/\/docs.splunk.com\/Documentation\/Splunk\/latest\/SearchReference\/rex\" rel=\"nofollow noreferrer\"><em>but<\/em><\/a> a [possibly-present] UUID, just <a href=\"https:\/\/docs.splunk.com\/Documentation\/Splunk\/latest\/SearchReference\/eval\" rel=\"nofollow noreferrer\"><em>remove<\/em><\/a> it <a href=\"https:\/\/docs.splunk.com\/Documentation\/Splunk\/latest\/SearchReference\/TextFunctions#replace.28X.2CY.2CZ.29\" rel=\"nofollow noreferrer\">instead<\/a> (and then remove extra spaces):<\/p>\n<pre><code>index=ndx sourcetype=srctp message=*\n| eval error_msg=replace(message,&quot;\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}&quot;,&quot;&quot;)\n| eval error_msg=replace(error_msg,&quot;\\s+&quot;,&quot; &quot;)\n<\/code><\/pre>\n<p>If you know that the UUID is always contained inside whitespace, you could make the first <code>replace()<\/code> more efficient thusly:<\/p>\n<pre><code>| eval error_msg=replace(message,&quot;\\s\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}\\s&quot;,&quot;&quot;)\n<\/code><\/pre>\n<p>from User warren &#8211; Stack Overflow https:\/\/stackoverflow.com\/questions\/73204968\/regular-expression-to-exclude-uuid-from-capture-group\/73207403#73207403<br \/>\nvia <a href=\"https:\/\/ifttt.com\/?ref=da&#038;site=wordpress\">IFTTT<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Instead of trying to capture everything but a [possibly-present] UUID, just remove it instead (and then remove extra spaces): index=ndx sourcetype=srctp message=* | eval error_msg=replace(message,&quot;\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}&quot;,&quot;&quot;) | eval error_msg=replace(error_msg,&quot;\\s+&quot;,&quot; &quot;) If you know that the UUID is always contained inside whitespace, you could make the first replace() more efficient thusly: | eval error_msg=replace(message,&quot;\\s\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}\\s&quot;,&quot;&quot;) from User warren &hellip;<br \/><a href=\"https:\/\/merikebi.warrenmyers.com\/?p=61296\" class=\"more-link pen_button pen_element_default pen_icon_arrow_double\">Continue reading <span class=\"screen-reader-text\">Answer by warren for Regular expression to exclude UUID from capture group<\/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-61296","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\/61296","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=61296"}],"version-history":[{"count":1,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/61296\/revisions"}],"predecessor-version":[{"id":61297,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/61296\/revisions\/61297"}],"wp:attachment":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=61296"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=61296"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=61296"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fkeyring_services&post=61296"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}