{"id":25419,"date":"2020-11-19T19:37:30","date_gmt":"2020-11-19T19:37:30","guid":{"rendered":"https:\/\/merikebi.warrenmyers.com\/?p=25419"},"modified":"2020-11-19T19:37:30","modified_gmt":"2020-11-19T19:37:30","slug":"answer-by-warren-for-splunk-how-to-use-multiple-regular-expressions-in-one-query","status":"publish","type":"post","link":"https:\/\/merikebi.warrenmyers.com\/?p=25419","title":{"rendered":"Answer by warren for Splunk: How to use multiple regular expressions in one query?"},"content":{"rendered":"<p>I generally try to avoid putting multiple field extracts in a single <a href=\"https:\/\/docs.splunk.com\/Documentation\/Splunk\/latest\/SearchReference\/rex\" rel=\"nofollow noreferrer\"><code>rex<\/code><\/a><\/p>\n<p>Instead, I go for sequential ones like this:<\/p>\n<pre><code>&lt;search&gt;\n| rex field=_raw &quot;(?&lt;ip&gt;\\d+\\.\\d+\\.\\d+\\.\\d+):&quot;\n| rex field=_raw &quot;\\d+:(?&lt;port&gt;\\d+)&quot;\n| rex field=_raw &quot;\\d+:\\d+\\s+(?&lt;msg&gt;.+)&quot;\n&lt;more stuff here&gt;\n<\/code><\/pre>\n<p>In this example, I&#8217;m pulling an IP, port, and some message afterwards into three new fields: <code>ip<\/code>, <code>port<\/code>, <code>msg<\/code><\/p>\n<p>Of course, if you <em>can<\/em> this should be done in <a href=\"https:\/\/docs.splunk.com\/Documentation\/Splunk\/latest\/Admin\/Propsconf\" rel=\"nofollow noreferrer\"><code>props.conf<\/code><\/a> &#8230;but that&#8217;s not always possible<\/p>\n<p>from User warren &#8211; Stack Overflow https:\/\/stackoverflow.com\/questions\/64915269\/splunk-how-to-use-multiple-regular-expressions-in-one-query\/64918787#64918787<br \/>\nvia <a href=\"https:\/\/ifttt.com\/?ref=da&#038;site=wordpress\">IFTTT<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I generally try to avoid putting multiple field extracts in a single rex Instead, I go for sequential ones like this: &lt;search&gt; | rex field=_raw &quot;(?&lt;ip&gt;\\d+\\.\\d+\\.\\d+\\.\\d+):&quot; | rex field=_raw &quot;\\d+:(?&lt;port&gt;\\d+)&quot; | rex field=_raw &quot;\\d+:\\d+\\s+(?&lt;msg&gt;.+)&quot; &lt;more stuff here&gt; In this example, I&#8217;m pulling an IP, port, and some message afterwards into three new fields: ip, port, &hellip;<br \/><a href=\"https:\/\/merikebi.warrenmyers.com\/?p=25419\" class=\"more-link pen_button pen_element_default pen_icon_arrow_double\">Continue reading <span class=\"screen-reader-text\">Answer by warren for Splunk: How to use multiple regular expressions in one query?<\/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-25419","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\/25419","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=25419"}],"version-history":[{"count":1,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/25419\/revisions"}],"predecessor-version":[{"id":25420,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/25419\/revisions\/25420"}],"wp:attachment":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=25419"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=25419"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=25419"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fkeyring_services&post=25419"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}