<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How do I remove a string between the first occurrence of two strings in a query? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-remove-a-string-between-the-first-occurrence-of-two/m-p/420373#M120838</link>
    <description>&lt;P&gt;Thanks this did exactly what i needed, much appreciated. &lt;/P&gt;</description>
    <pubDate>Tue, 09 Oct 2018 15:35:58 GMT</pubDate>
    <dc:creator>Wondergoat77</dc:creator>
    <dc:date>2018-10-09T15:35:58Z</dc:date>
    <item>
      <title>How do I remove a string between the first occurrence of two strings in a query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-remove-a-string-between-the-first-occurrence-of-two/m-p/420370#M120835</link>
      <description>&lt;P&gt;I am trying to remove all content returned in a field between two specific strings but only from the first occurrence of these strings.&lt;/P&gt;

&lt;P&gt;I need to do this for a few sections of a log, strings I need to replace look like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[code= and ] : replace with empty string
[txid= and ] : replace with empty string
"code":"someCode" : either replace with empty string or only replace the "someCode" section.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Example log:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{"status":500,"statusDesc":"Internal Server Error","code":"someCode","message":"some error message"} [code=919285284] [txid=5f6c0952-5184-4bdd-9658-6487dfaeaf3f] }
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want the result to be:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; {"status":500,"statusDesc":"Internal Server Error","message":"some error message"}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am essentially trying to remove unique identifiers from this entry so that I can dedup based on the generic log error.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Oct 2018 22:30:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-remove-a-string-between-the-first-occurrence-of-two/m-p/420370#M120835</guid>
      <dc:creator>Wondergoat77</dc:creator>
      <dc:date>2018-10-08T22:30:14Z</dc:date>
    </item>
    <item>
      <title>Re: How do I remove a string between the first occurrence of two strings in a query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-remove-a-string-between-the-first-occurrence-of-two/m-p/420371#M120836</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Your Search Here
| rex "^{(?&amp;lt;curlytext&amp;gt;[^}]+)"
| dedup curlytext
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Oct 2018 00:36:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-remove-a-string-between-the-first-occurrence-of-two/m-p/420371#M120836</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2018-10-09T00:36:07Z</dc:date>
    </item>
    <item>
      <title>Re: How do I remove a string between the first occurrence of two strings in a query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-remove-a-string-between-the-first-occurrence-of-two/m-p/420372#M120837</link>
      <description>&lt;P&gt;Hi Wondergoat77,&lt;/P&gt;

&lt;P&gt;try this &lt;CODE&gt;rex&lt;/CODE&gt; SPL which uses &lt;CODE&gt;mode=sed&lt;/CODE&gt; to removes the various strings:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval foo="{\"status\":500,\"statusDesc\":\"Internal Server Error\",\"code\":\"someCode\",\"message\":\"some error message\"} [code=919285284] [txid=5f6c0952-5184-4bdd-9658-6487dfaeaf3f] }" 
| rex field=foo mode=sed "s/\[[^\]]+\]|\s\}|\"code\":\"[^\"]+\"//g"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The result looks like this:&lt;BR /&gt;
&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/5903i7726967C9C10F8F3/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2018 01:21:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-remove-a-string-between-the-first-occurrence-of-two/m-p/420372#M120837</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2018-10-09T01:21:27Z</dc:date>
    </item>
    <item>
      <title>Re: How do I remove a string between the first occurrence of two strings in a query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-remove-a-string-between-the-first-occurrence-of-two/m-p/420373#M120838</link>
      <description>&lt;P&gt;Thanks this did exactly what i needed, much appreciated. &lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2018 15:35:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-remove-a-string-between-the-first-occurrence-of-two/m-p/420373#M120838</guid>
      <dc:creator>Wondergoat77</dc:creator>
      <dc:date>2018-10-09T15:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: How do I remove a string between the first occurrence of two strings in a query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-remove-a-string-between-the-first-occurrence-of-two/m-p/420374#M120839</link>
      <description>&lt;P&gt;Awesome, feel free to accept the answer so it is marked as answered &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; &lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2018 18:56:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-remove-a-string-between-the-first-occurrence-of-two/m-p/420374#M120839</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2018-10-09T18:56:26Z</dc:date>
    </item>
  </channel>
</rss>

