<?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: Replace String Values in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Replace-String-Values/m-p/547180#M155131</link>
    <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp; and&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Apologies.&lt;/P&gt;&lt;P&gt;The &lt;STRONG&gt;LIST&lt;/STRONG&gt; is from a lookup table.&lt;/P&gt;&lt;P&gt;I will test out both of your answers and reply later today.&lt;/P&gt;&lt;P&gt;Thanks and God bless,&lt;BR /&gt;Genesius&lt;/P&gt;</description>
    <pubDate>Thu, 08 Apr 2021 12:14:16 GMT</pubDate>
    <dc:creator>genesiusj</dc:creator>
    <dc:date>2021-04-08T12:14:16Z</dc:date>
    <item>
      <title>Replace String Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-String-Values/m-p/547103#M155102</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I need to remove the values found (string) from another field.&lt;/P&gt;&lt;P&gt;Ex.&amp;nbsp;&lt;BR /&gt;FIELD1 - abcmailingxyz&lt;BR /&gt;LIST - mailing, ...&lt;BR /&gt;Using&amp;nbsp;| eval foundIt=if(match(FIELD1,$LIST$),"X",".") I am able to determine if the list of words are contained in the values for FIELD1&lt;/P&gt;&lt;P&gt;After the eval has found the match, foundIt=X, I need to remove the word "mailing" from the value of FIELD1.&lt;BR /&gt;Result - abcxyz (or abc_xyz if we decide to use an underscore in between).&lt;/P&gt;&lt;P&gt;Question.&lt;BR /&gt;How do I take the value in LIST and remove it from the value in FIELD1, leaving the remaining letters behind?&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;BR /&gt;God bless, safe and healthy to you and yours,&lt;BR /&gt;Genesius&lt;/P&gt;</description>
      <pubDate>Wed, 07 Apr 2021 21:02:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-String-Values/m-p/547103#M155102</guid>
      <dc:creator>genesiusj</dc:creator>
      <dc:date>2021-04-07T21:02:10Z</dc:date>
    </item>
    <item>
      <title>Re: Replace String Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-String-Values/m-p/547123#M155112</link>
      <description>&lt;P&gt;I am not sure how your existing match is working if you have multiple values in the list - and with your surrounding LIST with $$ - is this in a dashboard and is that a token?&lt;/P&gt;&lt;P&gt;Anyway, if&amp;nbsp;you are using Splunk 8, then you could do it this way&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| fields - _time
| eval n=mvrange(1,11)
| mvexpand n
| eval FIELD1=mvindex(split("abcmailingxyz,test_splunkquery,otheroptiontext,errorinnetwork,nnnmailing2,nomatchesanywhere", ","), random() % 6)
| eval LIST=split("mailing,other,network,splunk", ",")
| eval match=mvmap(LIST,if(match(FIELD1,LIST),LIST,null))
| eval match=coalesce(match, "&amp;lt;&amp;lt;No Match Found&amp;gt;&amp;gt;")
| eval FIELD1_REPLACED=replace(FIELD1,match, "")
| table FIELD1 FIELD1_REPLACED match&lt;/LI-CODE&gt;&lt;P&gt;where the key function is the MVMAP line and it is taking your list values (which is a multivalue field containing your match strings) and then the replace() function is removing the match found to create the new FIELD1_REPLACED&lt;/P&gt;&lt;P&gt;Hope this helps&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Apr 2021 22:24:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-String-Values/m-p/547123#M155112</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2021-04-07T22:24:47Z</dc:date>
    </item>
    <item>
      <title>Re: Replace String Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-String-Values/m-p/547126#M155114</link>
      <description>&lt;P&gt;Assuming your list can be made into a pipe-delimited string, this acts as an or in the regex used by replace, so you can replace any of the values in the list with an empty string&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw="field1,list
abcmailingdef,mailing|post
pqrpostxyz,mailing|post
defmailingpostrst,mailing|post
nothingmatch,mailing|post"
| multikv forceheader=1
| fields field1 list
| fields - _*

| eval field2=replace(field1,list,"")&lt;/LI-CODE&gt;&lt;P&gt;Each event with field1 can have different values in their list if this is helpful too&lt;/P&gt;</description>
      <pubDate>Wed, 07 Apr 2021 22:37:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-String-Values/m-p/547126#M155114</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-04-07T22:37:30Z</dc:date>
    </item>
    <item>
      <title>Re: Replace String Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-String-Values/m-p/547180#M155131</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp; and&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Apologies.&lt;/P&gt;&lt;P&gt;The &lt;STRONG&gt;LIST&lt;/STRONG&gt; is from a lookup table.&lt;/P&gt;&lt;P&gt;I will test out both of your answers and reply later today.&lt;/P&gt;&lt;P&gt;Thanks and God bless,&lt;BR /&gt;Genesius&lt;/P&gt;</description>
      <pubDate>Thu, 08 Apr 2021 12:14:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-String-Values/m-p/547180#M155131</guid>
      <dc:creator>genesiusj</dc:creator>
      <dc:date>2021-04-08T12:14:16Z</dc:date>
    </item>
    <item>
      <title>Re: Replace String Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-String-Values/m-p/547434#M155244</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pulled onto other priorities. Still checking your responses.&lt;/P&gt;&lt;P&gt;Meanwhile, bosemana.&lt;BR /&gt;&lt;STRONG&gt;&lt;SPAN&gt;&amp;nbsp;| eval foundIt=if(match(FIELD1,$LIST$),"X",".")&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;BR /&gt;The &lt;STRONG&gt;$LIST$&lt;/STRONG&gt; is not a dashboard token. The match function uses regex syntax. Therefore, it is checking to see if the value contained in the &lt;STRONG&gt;LIST&lt;/STRONG&gt; field matches &lt;STRONG&gt;FIELD1&lt;/STRONG&gt;. Without the $$ I believe it would be checking to see if the word &lt;STRONG&gt;LIST&lt;/STRONG&gt; was in &lt;STRONG&gt;FIELD1&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;Apologies to both of you. I work with &lt;STRONG&gt;makeresults&lt;/STRONG&gt;. However, when multivalue commands are used with &lt;STRONG&gt;makeresults&lt;/STRONG&gt; I tend to misunderstand which &lt;STRONG&gt;mv&lt;/STRONG&gt; commands are present because of &lt;STRONG&gt;makeresults&lt;/STRONG&gt;, and which are part of the solution when there is a data source.&lt;/P&gt;&lt;P&gt;To further clarify.&lt;BR /&gt;&lt;STRONG&gt;FIELD1&lt;/STRONG&gt; is an email address, minus the @ and domain name.&lt;BR /&gt;&lt;STRONG&gt;LIST&lt;/STRONG&gt; is a lookup table with over 100 computer-related terms.&lt;BR /&gt;We need to find email addresses that contain these computer-related terms; remove them when found; list the found terms; leave the remaining characters from the email address.&lt;/P&gt;&lt;P&gt;Example&lt;BR /&gt;FIELD1 email addresses&lt;BR /&gt;abc&lt;STRONG&gt;processor&lt;/STRONG&gt;123&lt;BR /&gt;&lt;STRONG&gt;digital&lt;/STRONG&gt;xyz&lt;STRONG&gt;monitor&lt;/STRONG&gt;&lt;BR /&gt;fgh&lt;STRONG&gt;cpuscreen&lt;/STRONG&gt;1313&lt;STRONG&gt;drive&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;List of words (and count)&lt;BR /&gt;&lt;STRONG&gt;processor&lt;/STRONG&gt; 1&lt;BR /&gt;&lt;STRONG&gt;digital&lt;/STRONG&gt; &lt;STRONG&gt;monitor&lt;/STRONG&gt; 2&lt;BR /&gt;&lt;STRONG&gt;cpu&lt;/STRONG&gt; &lt;STRONG&gt;screen&lt;/STRONG&gt; &lt;STRONG&gt;drive&lt;/STRONG&gt; 3&lt;/P&gt;&lt;P&gt;Remaining characters (using ..,::,|| for the LIST words removed)&lt;BR /&gt;abc&lt;STRONG&gt;..&lt;/STRONG&gt;123&lt;BR /&gt;&lt;STRONG&gt;..&lt;/STRONG&gt;xyz&lt;STRONG&gt;::&lt;/STRONG&gt;&lt;BR /&gt;fgh.&lt;STRONG&gt;.::&lt;/STRONG&gt;1313&lt;STRONG&gt;||&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help. Enjoy your weekend.&lt;BR /&gt;God bless,&lt;BR /&gt;Genesius&lt;/P&gt;</description>
      <pubDate>Fri, 09 Apr 2021 19:51:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-String-Values/m-p/547434#M155244</guid>
      <dc:creator>genesiusj</dc:creator>
      <dc:date>2021-04-09T19:51:09Z</dc:date>
    </item>
    <item>
      <title>Re: Replace String Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-String-Values/m-p/547533#M155266</link>
      <description>&lt;P&gt;I am not sure why you are surrounding LIST with $$. If you just use LIST then it is the field name LIST, whereas if you use quotes "LIST" then it is the string LIST.&amp;nbsp;&lt;/P&gt;&lt;P&gt;This will do what you want as long as you have Splunk 8&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| fields - _time
| eval n=mvrange(0,3)
| mvexpand n
| eval FIELD1=mvindex(split("abcprocessor123,digitalxyzmonitor,fghcpuscreen1313drive", ","), n)
| eval LIST=split("mailing,other,network,splunk,processor,cpu,screen,drive,digital,monitor", ",")
| eval match=mvmap(LIST,if(match(FIELD1,LIST),LIST,null))
| eval match=coalesce(match, "&amp;lt;&amp;lt;No Match Found&amp;gt;&amp;gt;")
| eval matchStr=mvjoin(match,"|")
| eval FIELD1_REPLACED=replace(FIELD1,matchStr, "")
| eval replaceCount=mvcount(match)
| table FIELD1 FIELD1_REPLACED match replaceCount&lt;/LI-CODE&gt;&lt;P&gt;Paste this into the search window and it will show you your results.&lt;/P&gt;&lt;P&gt;To make this work for you, you need to&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;create the variable LIST which is the multi value field containing all of your exclusion words&lt;/LI&gt;&lt;LI&gt;use these lines that actually do the work for you&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="markup"&gt;| eval match=mvmap(LIST,if(match(FIELD1,LIST),LIST,null))
| eval matchStr=mvjoin(match,"|")
| eval FIELD1_REPLACED=replace(FIELD1,matchStr, "")
| eval replaceCount=mvcount(match)&lt;/LI-CODE&gt;&lt;P&gt;the removal is done by the replace statement using the regex of a|b|c where a, b and c are the words found in your email address from the list of words&lt;/P&gt;&lt;P&gt;replaceCount is just getting the number of matches&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Apr 2021 11:03:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-String-Values/m-p/547533#M155266</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2021-04-11T11:03:20Z</dc:date>
    </item>
    <item>
      <title>Re: Replace String Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-String-Values/m-p/547629#M155298</link>
      <description>&lt;P&gt;Good morning,&amp;nbsp;&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;According to the Splunk docs, the match function uses regex, which is why I am using the $LIST$.&lt;BR /&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.1.3/SearchReference/ConditionalFunctions" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/8.1.3/SearchReference/ConditionalFunctions&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I found the article where I learned about the $LIST$.&lt;BR /&gt;&lt;A href="https://tinyinput.blogspot.com/2017/02/splunk-do-you-like-or-do-you-match.html" target="_blank"&gt;https://tinyinput.blogspot.com/2017/02/splunk-do-you-like-or-do-you-match.html&lt;/A&gt;&lt;BR /&gt;I read through the article &lt;STRONG&gt;&lt;EM&gt;too quickly and missed&lt;/EM&gt; &lt;/STRONG&gt;that the author was in a section concerning dashboards. My bad. However, using $LIST$ does work. Interesting.&lt;/P&gt;&lt;P&gt;I have yet to try your latest update. I will hopefully advise shortly.&lt;/P&gt;&lt;P&gt;Thanks and God bless,&lt;BR /&gt;Genesius&lt;/P&gt;</description>
      <pubDate>Mon, 12 Apr 2021 14:54:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-String-Values/m-p/547629#M155298</guid>
      <dc:creator>genesiusj</dc:creator>
      <dc:date>2021-04-12T14:54:21Z</dc:date>
    </item>
    <item>
      <title>Re: Replace String Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-String-Values/m-p/547646#M155302</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Thank you for breaking the SPL needed into a separate section.&lt;BR /&gt;This worked like a charm.&lt;BR /&gt;God bless,&lt;BR /&gt;Genesius&lt;/P&gt;</description>
      <pubDate>Mon, 12 Apr 2021 18:59:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-String-Values/m-p/547646#M155302</guid>
      <dc:creator>genesiusj</dc:creator>
      <dc:date>2021-04-12T18:59:58Z</dc:date>
    </item>
  </channel>
</rss>

