<?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 Can I remove a part of a string? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Can-I-remove-a-part-of-a-string/m-p/453762#M167583</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Is there an eval command that will remove the last part of a string.&lt;/P&gt;

&lt;P&gt;For example:&lt;BR /&gt;
"Installed - 5%" will be come "Installed"&lt;BR /&gt;
"Not Installed - 95%" will become "Not Installed"&lt;BR /&gt;
Basically remove " - *%" from a string&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Tue, 11 Sep 2018 03:41:41 GMT</pubDate>
    <dc:creator>baty0</dc:creator>
    <dc:date>2018-09-11T03:41:41Z</dc:date>
    <item>
      <title>Can I remove a part of a string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-remove-a-part-of-a-string/m-p/453762#M167583</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Is there an eval command that will remove the last part of a string.&lt;/P&gt;

&lt;P&gt;For example:&lt;BR /&gt;
"Installed - 5%" will be come "Installed"&lt;BR /&gt;
"Not Installed - 95%" will become "Not Installed"&lt;BR /&gt;
Basically remove " - *%" from a string&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2018 03:41:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-remove-a-part-of-a-string/m-p/453762#M167583</guid>
      <dc:creator>baty0</dc:creator>
      <dc:date>2018-09-11T03:41:41Z</dc:date>
    </item>
    <item>
      <title>Re: Can I remove a part of a string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-remove-a-part-of-a-string/m-p/453763#M167584</link>
      <description>&lt;P&gt;hi @baty0&lt;/P&gt;

&lt;P&gt;try like this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults |eval hari="Installed - 5%" |append [| makeresults |eval  hari="Not Installed - 95%" ] |table hari |eval results=split(hari," -") |eval hari=mvindex(results,0) |table hari
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Sep 2018 05:59:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-remove-a-part-of-a-string/m-p/453763#M167584</guid>
      <dc:creator>harishalipaka</dc:creator>
      <dc:date>2018-09-11T05:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: Can I remove a part of a string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-remove-a-part-of-a-string/m-p/453764#M167585</link>
      <description>&lt;P&gt;Hey, you can extract using &lt;CODE&gt;rex&lt;/CODE&gt; command as well. with eval, you would have to use 2 steps and rex is 1 step solution:&lt;BR /&gt;
Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval data="Installed - 5%,Not Installed - 95%" 
| makemv data delim="," 
| mvexpand data 
| table data| rex field=data "(?&amp;lt;newfield&amp;gt;[^\-]+)\s"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;let me know if this helps!&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2018 09:31:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-remove-a-part-of-a-string/m-p/453764#M167585</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2018-09-11T09:31:37Z</dc:date>
    </item>
    <item>
      <title>Re: Can I remove a part of a string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-remove-a-part-of-a-string/m-p/453765#M167586</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;You can use the eval replace() function to replace the " - ##%" values with regex as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval foo = "Installed - 5%" 
| eval bar = "Not Installed - 95%"
| eval foo_replaced=replace(foo,"\s\-\s\d+\%",""), bar_replaced=replace(bar,"\s\-\s\d+\%","")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Sep 2018 18:00:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-remove-a-part-of-a-string/m-p/453765#M167586</guid>
      <dc:creator>zonistj</dc:creator>
      <dc:date>2018-09-11T18:00:50Z</dc:date>
    </item>
    <item>
      <title>Re: Can I remove a part of a string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-remove-a-part-of-a-string/m-p/453766#M167587</link>
      <description>&lt;P&gt;I have a use case where i need to pass the previously performed search query to replace the part of message with empty string.&lt;/P&gt;

&lt;P&gt;environment="dev" domain="test" logger_name="com.test.practice.demo.sse.impl.EventEncrypter" message="*Data = *"| eval message=replace(message," Data = ","")&lt;/P&gt;

&lt;P&gt;The above message in turn obtained must be used to do another operation. &lt;/P&gt;

&lt;P&gt;But the replace function itself is not working when i did a splunk search query. I am able to see the log with "Data =" being not removed and came as it is.&lt;/P&gt;

&lt;P&gt;I need to do this asap. can u pls provide a solution ?&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2020 11:57:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-remove-a-part-of-a-string/m-p/453766#M167587</guid>
      <dc:creator>d942725</dc:creator>
      <dc:date>2020-01-31T11:57:08Z</dc:date>
    </item>
    <item>
      <title>Re: Can I remove a part of a string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-remove-a-part-of-a-string/m-p/453767#M167588</link>
      <description>&lt;P&gt;@d942725 Please post a new question.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2020 13:30:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-remove-a-part-of-a-string/m-p/453767#M167588</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-01-31T13:30:55Z</dc:date>
    </item>
  </channel>
</rss>

