<?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: replacing parts inside string in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/replacing-parts-inside-string/m-p/343941#M101891</link>
    <description>&lt;P&gt;Yeah, in my query on dashboard&lt;/P&gt;</description>
    <pubDate>Mon, 12 Jun 2017 20:36:45 GMT</pubDate>
    <dc:creator>exocore123</dc:creator>
    <dc:date>2017-06-12T20:36:45Z</dc:date>
    <item>
      <title>replacing parts inside string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/replacing-parts-inside-string/m-p/343930#M101880</link>
      <description>&lt;P&gt;I had a field of this value &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;nameSpaces = ["url1"] 
nameSpaces = ["url1", "url2"]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I got &lt;CODE&gt;rex&lt;/CODE&gt; to change &lt;CODE&gt;["url1", "url2"]&lt;/CODE&gt; into &lt;CODE&gt;"url1, url2"&lt;/CODE&gt;&lt;BR /&gt;
However, I am trying to change url1 to a label1, and url2 to label2, is there a way I can change it so the outcome from&lt;BR /&gt;
&lt;CODE&gt;"url1, url2"&lt;/CODE&gt; to &lt;CODE&gt;"label1, label2"&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2017 16:31:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/replacing-parts-inside-string/m-p/343930#M101880</guid>
      <dc:creator>exocore123</dc:creator>
      <dc:date>2017-06-12T16:31:27Z</dc:date>
    </item>
    <item>
      <title>Re: replacing parts inside string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/replacing-parts-inside-string/m-p/343931#M101881</link>
      <description>&lt;P&gt;I saw I can use rex sed mode, but I am a bit confused on mapping the string. Originally I used spath and then replace for the labels, but I noticed they showed up as single records, and messed up the total count for the logs, so I am trying to maintain the proper length of the array. I was thinking &lt;CODE&gt;rex mode=sed "s/url1/label1"&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2017 16:32:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/replacing-parts-inside-string/m-p/343931#M101881</guid>
      <dc:creator>exocore123</dc:creator>
      <dc:date>2017-06-12T16:32:31Z</dc:date>
    </item>
    <item>
      <title>Re: replacing parts inside string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/replacing-parts-inside-string/m-p/343932#M101882</link>
      <description>&lt;P&gt;Try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your current search giving field nameSpaces
| rex field=nameSpaces mode=sed "s/url/label/g"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Jun 2017 16:43:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/replacing-parts-inside-string/m-p/343932#M101882</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-06-12T16:43:02Z</dc:date>
    </item>
    <item>
      <title>Re: replacing parts inside string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/replacing-parts-inside-string/m-p/343933#M101883</link>
      <description>&lt;P&gt;Perfect! what about if I had url1 and url3, and they're both the same, can I somehow condense it to &lt;CODE&gt;rex field=nameSpaces mode=sed "s/url1 | url3/label/g"&lt;/CODE&gt; as well as multiple fields?&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2017 16:51:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/replacing-parts-inside-string/m-p/343933#M101883</guid>
      <dc:creator>exocore123</dc:creator>
      <dc:date>2017-06-12T16:51:02Z</dc:date>
    </item>
    <item>
      <title>Re: replacing parts inside string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/replacing-parts-inside-string/m-p/343934#M101884</link>
      <description>&lt;P&gt;You could do like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| rex field=nameSpaces mode=sed "s/(ur1|url3)/label/g"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Jun 2017 17:02:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/replacing-parts-inside-string/m-p/343934#M101884</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-06-12T17:02:56Z</dc:date>
    </item>
    <item>
      <title>Re: replacing parts inside string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/replacing-parts-inside-string/m-p/343935#M101885</link>
      <description>&lt;P&gt;Thanks! What about &lt;CODE&gt;field=nameSpaces|nameSpaces2 mode=sed "s/(ur1|url3)/label/g"&lt;/CODE&gt;? Something similar? I tried that and did not work&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2017 17:07:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/replacing-parts-inside-string/m-p/343935#M101885</guid>
      <dc:creator>exocore123</dc:creator>
      <dc:date>2017-06-12T17:07:35Z</dc:date>
    </item>
    <item>
      <title>Re: replacing parts inside string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/replacing-parts-inside-string/m-p/343936#M101886</link>
      <description>&lt;P&gt;You can't specify multiple fields in &lt;CODE&gt;field&lt;/CODE&gt; attribute of rex command. You can either run rex multiple time for each nameSpace field, or use foreach command like this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | foreach nameSpaces* [rex field="&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;" mode=sed "s/(url1|url3)/label/g" ]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Jun 2017 17:19:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/replacing-parts-inside-string/m-p/343936#M101886</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-06-12T17:19:22Z</dc:date>
    </item>
    <item>
      <title>Re: replacing parts inside string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/replacing-parts-inside-string/m-p/343937#M101887</link>
      <description>&lt;P&gt;well technically my nameSpaces are two different fields (name wise), so I guess I am going to have to make duplicate rex lines then, maybe possibly &lt;CODE&gt;rename&lt;/CODE&gt;?&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2017 17:28:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/replacing-parts-inside-string/m-p/343937#M101887</guid>
      <dc:creator>exocore123</dc:creator>
      <dc:date>2017-06-12T17:28:52Z</dc:date>
    </item>
    <item>
      <title>Re: replacing parts inside string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/replacing-parts-inside-string/m-p/343938#M101888</link>
      <description>&lt;P&gt;I accidentally added a space after nameSpace in above foreach command. I'm using &lt;CODE&gt;*&lt;/CODE&gt; as wildcard so any field which starts with nameSpace will get that replacement.&lt;/P&gt;

&lt;P&gt;And yes, other option would be to add multiple rex commands for each nameSpaceN field.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2017 17:33:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/replacing-parts-inside-string/m-p/343938#M101888</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-06-12T17:33:00Z</dc:date>
    </item>
    <item>
      <title>Re: replacing parts inside string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/replacing-parts-inside-string/m-p/343939#M101889</link>
      <description>&lt;P&gt;I got an &lt;CODE&gt;"Unencoded &amp;lt;"&lt;/CODE&gt; error when using &lt;CODE&gt;foreach nameSpaces* [rex field="&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;" mode=sed "s/(url1|url3)/label/g" ]&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2017 18:03:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/replacing-parts-inside-string/m-p/343939#M101889</guid>
      <dc:creator>exocore123</dc:creator>
      <dc:date>2017-06-12T18:03:26Z</dc:date>
    </item>
    <item>
      <title>Re: replacing parts inside string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/replacing-parts-inside-string/m-p/343940#M101890</link>
      <description>&lt;P&gt;Are you trying to run it from dashboard?&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2017 18:57:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/replacing-parts-inside-string/m-p/343940#M101890</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-06-12T18:57:41Z</dc:date>
    </item>
    <item>
      <title>Re: replacing parts inside string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/replacing-parts-inside-string/m-p/343941#M101891</link>
      <description>&lt;P&gt;Yeah, in my query on dashboard&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2017 20:36:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/replacing-parts-inside-string/m-p/343941#M101891</guid>
      <dc:creator>exocore123</dc:creator>
      <dc:date>2017-06-12T20:36:45Z</dc:date>
    </item>
    <item>
      <title>Re: replacing parts inside string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/replacing-parts-inside-string/m-p/343942#M101892</link>
      <description>&lt;P&gt;Guessing you're updating the dashboard xml directly, use the foreach like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...|  foreach nameSpaces* [rex field="&amp;amp;lt;&amp;amp;lt;FIELD&amp;amp;gt;&amp;amp;gt;" mode=sed "s/(url1|url3)/label/g" ]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Jun 2017 21:01:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/replacing-parts-inside-string/m-p/343942#M101892</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-06-12T21:01:05Z</dc:date>
    </item>
  </channel>
</rss>

