<?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 can I edit field values? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-edit-field-values/m-p/290718#M87853</link>
    <description>&lt;P&gt;&lt;STRONG&gt;[Edit] Added Option 4 &lt;CODE&gt;rtrim()&lt;/CODE&gt;&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;PS: It is better to apply the &lt;CODE&gt;rex&lt;/CODE&gt; after the &lt;CODE&gt;chart&lt;/CODE&gt; command if it is just for massaging the results as per the need. even the eval to perform upper case.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="notrelevant" 
| chart count by Vegetables
| rex field=Vegetables "(?&amp;lt;Vegetables&amp;gt;[^/]+)/"
| eval Vegetables=upper(Vegetables)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;@TNRRVN93, seems like your Vegetables have an additional forward slash character &lt;CODE&gt;/&lt;/CODE&gt; in the end which you need to remove.&lt;BR /&gt;
There can be several ways of doing this like using &lt;CODE&gt;rex&lt;/CODE&gt; command or &lt;CODE&gt;replace()&lt;/CODE&gt; evaluation function. Try any of the following approach by appending to your existing &lt;CODE&gt;chart&lt;/CODE&gt; command.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Option 1)&lt;/STRONG&gt; Using &lt;CODE&gt;replace()&lt;/CODE&gt; with regular expression:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Vegetables=replace(Vegetables,"(.*)(/)$","\1")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Option 2)&lt;/STRONG&gt; Using &lt;CODE&gt;replace()&lt;/CODE&gt; with character to replace:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Vegetables=replace(Vegetables,"/","")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Option 3)&lt;/STRONG&gt; Using &lt;CODE&gt;rex&lt;/CODE&gt; command with Regular Expression:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=Vegetables "(?&amp;lt;Vegetables&amp;gt;[^/]+)/"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Option 4&lt;/STRONG&gt;: Using &lt;CODE&gt;rtrim()&lt;/CODE&gt; to remove forward slash from end.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Vegetables=rtrim(Vegetables,"/")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Following is a run-anywhere  search to generate some sample data and one of the options to replace forward slash.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval Vegetables="potato/",count="37"
| append [| makeresults
| eval Vegetables="tomato/",count="53"]
| append [| makeresults
| eval Vegetables="carrot/",count="13"]
| append [| makeresults
| eval Vegetables="spinach/",count="25"]
| table Vegetables count
| eval Vegetables=replace(Vegetables,"(.*)(/)$","\1")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 08 Oct 2017 15:56:11 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2017-10-08T15:56:11Z</dc:date>
    <item>
      <title>How can I edit field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-edit-field-values/m-p/290716#M87851</link>
      <description>&lt;P&gt;Hello together,&lt;/P&gt;

&lt;P&gt;I have the field &lt;EM&gt;Vegetables&lt;/EM&gt; with 5 field values. The field values are cucumber, tomato, onion, carrot and potato.&lt;BR /&gt;
When I am clicking to the field in the &lt;EM&gt;fields sidebar&lt;/EM&gt;, the field values are displayed with a slash (/) - such as &lt;STRONG&gt;carrot/&lt;/STRONG&gt;. And as well in the pie chart.&lt;BR /&gt;
&lt;STRONG&gt;I want to represent the values without the slash in the pie chart.&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;That is my search:&lt;BR /&gt;
sourcetype="notrelevant" | chart count by Vegetables&lt;/P&gt;

&lt;P&gt;I have already looked in the documentation and in other questions, but unfortunately I could not find a solution.&lt;BR /&gt;
Could you please help me?&lt;/P&gt;

&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Sun, 08 Oct 2017 15:14:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-edit-field-values/m-p/290716#M87851</guid>
      <dc:creator>TNRRVN93</dc:creator>
      <dc:date>2017-10-08T15:14:18Z</dc:date>
    </item>
    <item>
      <title>Re: How can I edit field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-edit-field-values/m-p/290717#M87852</link>
      <description>&lt;P&gt;If the values of &lt;CODE&gt;Vegetables&lt;/CODE&gt; has the slash at the &lt;STRONG&gt;end&lt;/STRONG&gt;, you should be able to use the following in your search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex mode=sed field=Vegetables "s#/$##" | ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 08 Oct 2017 15:55:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-edit-field-values/m-p/290717#M87852</guid>
      <dc:creator>cpetterborg</dc:creator>
      <dc:date>2017-10-08T15:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: How can I edit field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-edit-field-values/m-p/290718#M87853</link>
      <description>&lt;P&gt;&lt;STRONG&gt;[Edit] Added Option 4 &lt;CODE&gt;rtrim()&lt;/CODE&gt;&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;PS: It is better to apply the &lt;CODE&gt;rex&lt;/CODE&gt; after the &lt;CODE&gt;chart&lt;/CODE&gt; command if it is just for massaging the results as per the need. even the eval to perform upper case.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="notrelevant" 
| chart count by Vegetables
| rex field=Vegetables "(?&amp;lt;Vegetables&amp;gt;[^/]+)/"
| eval Vegetables=upper(Vegetables)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;@TNRRVN93, seems like your Vegetables have an additional forward slash character &lt;CODE&gt;/&lt;/CODE&gt; in the end which you need to remove.&lt;BR /&gt;
There can be several ways of doing this like using &lt;CODE&gt;rex&lt;/CODE&gt; command or &lt;CODE&gt;replace()&lt;/CODE&gt; evaluation function. Try any of the following approach by appending to your existing &lt;CODE&gt;chart&lt;/CODE&gt; command.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Option 1)&lt;/STRONG&gt; Using &lt;CODE&gt;replace()&lt;/CODE&gt; with regular expression:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Vegetables=replace(Vegetables,"(.*)(/)$","\1")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Option 2)&lt;/STRONG&gt; Using &lt;CODE&gt;replace()&lt;/CODE&gt; with character to replace:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Vegetables=replace(Vegetables,"/","")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Option 3)&lt;/STRONG&gt; Using &lt;CODE&gt;rex&lt;/CODE&gt; command with Regular Expression:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=Vegetables "(?&amp;lt;Vegetables&amp;gt;[^/]+)/"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Option 4&lt;/STRONG&gt;: Using &lt;CODE&gt;rtrim()&lt;/CODE&gt; to remove forward slash from end.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Vegetables=rtrim(Vegetables,"/")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Following is a run-anywhere  search to generate some sample data and one of the options to replace forward slash.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval Vegetables="potato/",count="37"
| append [| makeresults
| eval Vegetables="tomato/",count="53"]
| append [| makeresults
| eval Vegetables="carrot/",count="13"]
| append [| makeresults
| eval Vegetables="spinach/",count="25"]
| table Vegetables count
| eval Vegetables=replace(Vegetables,"(.*)(/)$","\1")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 08 Oct 2017 15:56:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-edit-field-values/m-p/290718#M87853</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-10-08T15:56:11Z</dc:date>
    </item>
    <item>
      <title>Re: How can I edit field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-edit-field-values/m-p/290719#M87854</link>
      <description>&lt;P&gt;@cpetterborg, luckily you have mentioned the alternate &lt;CODE&gt;rex&lt;/CODE&gt; with &lt;CODE&gt;sed&lt;/CODE&gt; that I missed! &lt;CODE&gt;You are truly beyond "regular" regular expressions!&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Oct 2017 16:01:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-edit-field-values/m-p/290719#M87854</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-10-08T16:01:58Z</dc:date>
    </item>
    <item>
      <title>Re: How can I edit field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-edit-field-values/m-p/290720#M87855</link>
      <description>&lt;P&gt;Use below rex command-&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="notrelevant" |rex field=Vegetables "(?&amp;lt;Vegetables&amp;gt;\w+)"| chart count by Vegetables
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It will work.&lt;/P&gt;</description>
      <pubDate>Sun, 08 Oct 2017 16:02:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-edit-field-values/m-p/290720#M87855</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2017-10-08T16:02:48Z</dc:date>
    </item>
    <item>
      <title>Re: How can I edit field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-edit-field-values/m-p/290721#M87856</link>
      <description>&lt;P&gt;Hello 493669,&lt;/P&gt;

&lt;P&gt;thank you very much!&lt;/P&gt;

&lt;P&gt;Do you know, how can I represent the values in upper case?&lt;BR /&gt;
Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Sun, 08 Oct 2017 16:26:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-edit-field-values/m-p/290721#M87856</guid>
      <dc:creator>TNRRVN93</dc:creator>
      <dc:date>2017-10-08T16:26:28Z</dc:date>
    </item>
    <item>
      <title>Re: How can I edit field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-edit-field-values/m-p/290722#M87857</link>
      <description>&lt;P&gt;Use Below:&lt;BR /&gt;
    eval Vegetables=upper(Vegetables)&lt;/P&gt;</description>
      <pubDate>Sun, 08 Oct 2017 16:35:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-edit-field-values/m-p/290722#M87857</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2017-10-08T16:35:12Z</dc:date>
    </item>
  </channel>
</rss>

