{"id":38552,"date":"2021-06-28T21:27:34","date_gmt":"2021-06-28T21:27:34","guid":{"rendered":"https:\/\/merikebi.warrenmyers.com\/?p=38552"},"modified":"2021-06-28T21:27:34","modified_gmt":"2021-06-28T21:27:34","slug":"answer-by-warren-for-splunk-split-a-field-into-multiple-fields-based-on-delimiters","status":"publish","type":"post","link":"https:\/\/merikebi.warrenmyers.com\/?p=38552","title":{"rendered":"Answer by warren for Splunk &#8211; Split a field into multiple fields based on delimiters"},"content":{"rendered":"<p>I almost always use multiple <a href=\"https:\/\/docs.splunk.com\/Documentation\/Splunk\/latest\/SearchReference\/rex\" rel=\"nofollow noreferrer\"><code>rex<\/code><\/a> statement to get what I want &#8230; but if you &quot;know&quot; the data is consistent, this will work (tried on <a href=\"https:\/\/regex101.com\/r\/RSqX6R\/1\" rel=\"nofollow noreferrer\">regex101.com<\/a>):<\/p>\n<pre><code>| rex field=_raw (?&lt;classname&gt;[^\\\/]+)\\\/(?&lt;featurename&gt;[^\\.]+)\\.[[:punct:]]+(?&lt;project&gt;[\\w].+)\n<\/code><\/pre>\n<p>What this regular expression does:<\/p>\n<ul>\n<li><code>&lt;classname&gt;<\/code> :: everything from the front of the event to a front slash (<code>\/<\/code>)<\/li>\n<li><code>&lt;featurename&gt;<\/code> :: whatever follows the front slash (<code>\/<\/code>) until a literal dot (<code>.<\/code>)<\/li>\n<li>discard all found punctuation<\/li>\n<li><code>&lt;project&gt;<\/code> :: whatever is left on the line<\/li>\n<\/ul>\n<p>According to regex101.com, this is <em>likely<\/em> the most efficient rex you can use (14 steps total)<\/p>\n<p>from User warren &#8211; Stack Overflow https:\/\/stackoverflow.com\/questions\/68169998\/splunk-split-a-field-into-multiple-fields-based-on-delimiters\/68170164#68170164<br \/>\nvia <a href=\"https:\/\/ifttt.com\/?ref=da&#038;site=wordpress\">IFTTT<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I almost always use multiple rex statement to get what I want &#8230; but if you &quot;know&quot; the data is consistent, this will work (tried on regex101.com): | rex field=_raw (?&lt;classname&gt;[^\\\/]+)\\\/(?&lt;featurename&gt;[^\\.]+)\\.[[:punct:]]+(?&lt;project&gt;[\\w].+) What this regular expression does: &lt;classname&gt; :: everything from the front of the event to a front slash (\/) &lt;featurename&gt; :: whatever follows the &hellip;<br \/><a href=\"https:\/\/merikebi.warrenmyers.com\/?p=38552\" class=\"more-link pen_button pen_element_default pen_icon_arrow_double\">Continue reading <span class=\"screen-reader-text\">Answer by warren for Splunk &#8211; Split a field into multiple fields based on delimiters<\/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-38552","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\/38552","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=38552"}],"version-history":[{"count":1,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/38552\/revisions"}],"predecessor-version":[{"id":38553,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/38552\/revisions\/38553"}],"wp:attachment":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=38552"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=38552"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=38552"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fkeyring_services&post=38552"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}