{"id":65445,"date":"2022-10-19T11:28:26","date_gmt":"2022-10-19T11:28:26","guid":{"rendered":"https:\/\/merikebi.warrenmyers.com\/?p=65445"},"modified":"2022-10-19T11:28:26","modified_gmt":"2022-10-19T11:28:26","slug":"answer-by-warren-for-exclude-string-from-matched-result-in-regex","status":"publish","type":"post","link":"https:\/\/merikebi.warrenmyers.com\/?p=65445","title":{"rendered":"Answer by warren for Exclude string from matched result in regex"},"content":{"rendered":"<blockquote>\n<p>Please note that I don;t have an option to use replace\/sub since I have to do this splunk.<\/p>\n<\/blockquote>\n<p>Splunk most certainly has ways of replacing values in strings &#8211; either by using <a href=\"https:\/\/docs.splunk.com\/Documentation\/Splunk\/latest\/SearchReference\/rex\" rel=\"nofollow noreferrer\"><code>rex<\/code><\/a> in <code>sed<\/code> mode, or by using <a href=\"https:\/\/docs.splunk.com\/Documentation\/Splunk\/latest\/SearchReference\/eval\" rel=\"nofollow noreferrer\"><code>eval replace()<\/code><\/a><\/p>\n<p>This regular expression will pull what you&#8217;re looking for:<\/p>\n<pre><code>| rex field=_raw &quot;\\&quot;(?&lt;subject&gt;[^\\&quot;]+)&quot;\n<\/code><\/pre>\n<p>Follow it by replacing the <code>\\r\\n<\/code>:<\/p>\n<pre><code>| eval subject=replace(subject,&quot;[\\r\\n]+&quot;,&quot;&quot;)\n<\/code><\/pre>\n<p>If that <code>replace<\/code> does not work for you (sometimes those hidden characters show up as sequential whitespace instead), do this:<\/p>\n<pre><code>| eval subject=replace(subject,&quot;\\s\\s+&quot;,&quot; &quot;)\n<\/code><\/pre>\n<p>from User warren &#8211; Stack Overflow https:\/\/stackoverflow.com\/questions\/74122892\/exclude-string-from-matched-result-in-regex\/74124502#74124502<br \/>\nvia <a href=\"https:\/\/ifttt.com\/?ref=da&#038;site=wordpress\">IFTTT<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Please note that I don;t have an option to use replace\/sub since I have to do this splunk. Splunk most certainly has ways of replacing values in strings &#8211; either by using rex in sed mode, or by using eval replace() This regular expression will pull what you&#8217;re looking for: | rex field=_raw &quot;\\&quot;(?&lt;subject&gt;[^\\&quot;]+)&quot; Follow &hellip;<br \/><a href=\"https:\/\/merikebi.warrenmyers.com\/?p=65445\" class=\"more-link pen_button pen_element_default pen_icon_arrow_double\">Continue reading <span class=\"screen-reader-text\">Answer by warren for Exclude string from matched result in regex<\/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-65445","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\/65445","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=65445"}],"version-history":[{"count":1,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/65445\/revisions"}],"predecessor-version":[{"id":65446,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/65445\/revisions\/65446"}],"wp:attachment":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=65445"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=65445"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=65445"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fkeyring_services&post=65445"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}