<?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 to use eval to change a field's value? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253626#M75919</link>
    <description>&lt;P&gt;@somesoni2 I tried a similar thing. On using two evals it is giving the error &lt;CODE&gt;Error in 'eval' command: Regex: quantifier does not follow a repeatable item&lt;/CODE&gt; I need to need to replace two different original character sequences with the same replacement character.&lt;/P&gt;</description>
    <pubDate>Thu, 06 Jul 2017 08:48:42 GMT</pubDate>
    <dc:creator>AshimaE</dc:creator>
    <dc:date>2017-07-06T08:48:42Z</dc:date>
    <item>
      <title>How to use eval to change a field's value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253605#M75898</link>
      <description>&lt;P&gt;Is it possible with EVAL do the following? I have a field named &lt;STRONG&gt;version&lt;/STRONG&gt; which brings the value like this:&lt;/P&gt;

&lt;P&gt;Version&lt;BR /&gt;
60101228&lt;BR /&gt;
50201315&lt;/P&gt;

&lt;P&gt;but I would like to change it for the following (and maintain the original)&lt;/P&gt;

&lt;P&gt;Version&lt;BR /&gt;
" 60101228 or 6.1.1228"&lt;BR /&gt;
"50201315 or  5.2.1315"&lt;/P&gt;

&lt;P&gt;Where a 0 (zero) is replaced for a dot (.). I need this because later I will need both values in a dynamic drop-down search in which values can appear in both ways.&lt;/P&gt;

&lt;P&gt;Can eval do this? Maybe other function? thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2016 12:44:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253605#M75898</guid>
      <dc:creator>guillecasco</dc:creator>
      <dc:date>2016-05-18T12:44:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to use eval to change a field's value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253606#M75899</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Yes but with rex&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|rex field=Version "(?&amp;lt;1&amp;gt;.)(?&amp;lt;2&amp;gt;.)(?&amp;lt;3&amp;gt;....)
| eval Version = 1.".".2.".".3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope i help you&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2016 13:49:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253606#M75899</guid>
      <dc:creator>jmallorquin</dc:creator>
      <dc:date>2016-05-18T13:49:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to use eval to change a field's value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253607#M75900</link>
      <description>&lt;P&gt;Try something like this. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 | eval Version="60101228 50201315" | makemv Version | mvexpand Version | table Version 
| eval Version1=replace(Version,"^(\d)(\d{2})(\d{2})(\d+)","\1\2\3\4 OR \1.\2.\3.\4")  
| eval Version2=replace(Version1,"(\d+)\sOR\s(\d)\.0*([^\.]+)\.0*([^\.]+)\.([^\.]+)","\1 OR \2.\3.\4.\5")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Line 1 is just to generate sample data, replace it with your search&lt;BR /&gt;
Line two gives a conversion (with leading 0s). If that works you can use just the line 2. If not, use both line 2 and line 3.&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2016 14:09:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253607#M75900</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-05-18T14:09:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to use eval to change a field's value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253608#M75901</link>
      <description>&lt;P&gt;maybe I wasn't quite clear. This is the search and results.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* usearch |rex "\"version\": \"(?\w*)\"" |dedup Version |table Version
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Version&lt;BR /&gt;
60201327&lt;BR /&gt;
60201528&lt;BR /&gt;
60201827&lt;BR /&gt;
60201429&lt;BR /&gt;
50201219&lt;BR /&gt;
50201413&lt;/P&gt;

&lt;P&gt;now i would like to replace those value  for :&lt;BR /&gt;
Version&lt;BR /&gt;
60201327 OR 6.2.1327&lt;BR /&gt;
60201528 OR 6.2.1528&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2016 14:49:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253608#M75901</guid>
      <dc:creator>guillecasco</dc:creator>
      <dc:date>2016-05-18T14:49:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to use eval to change a field's value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253609#M75902</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* usearch | rex "\"version\": \"(?\w*)\"" | dedup Version | eval version = replace(version,"0",".") | table Version
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 May 2016 16:18:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253609#M75902</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-05-18T16:18:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to use eval to change a field's value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253610#M75903</link>
      <description>&lt;P&gt;It's exactly what he gave but slightly modified:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=* usearch |rex "\"version\": \"(?\w*)\"" |dedup Version
| eval Version1=replace(Version,"^(\d)(\d{2})(\d{2})(\d+)","\1\2\3\4 OR \1.\2.\3.\4")  
| eval Version=replace(Version1,"(\d+)\sOR\s(\d)\.0*([^\.]+)\.0*([^\.]+)\.([^\.]+)","\1 OR \2.\3.\4.\5")
| table Version
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 May 2016 16:34:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253610#M75903</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-05-18T16:34:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to use eval to change a field's value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253611#M75904</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;index=* usearch 
|rex "\"version\": \"(?\w*)\"" 
|dedup Version
|rex field=Version mode=sed "s/(\d)(\d{2})(\d{2})(\d{3})/\1.\2.\3.\4/g" 
|eval Version=replace(Version,"0","") 
|table Version
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 May 2016 16:38:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253611#M75904</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-05-18T16:38:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to use eval to change a field's value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253612#M75905</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;index=* usearch
|rex "\"version\": \"(?&amp;lt;major&amp;gt;\d)(?&amp;lt;minor1&amp;gt;\d{2})(?&amp;lt;minor2&amp;gt;\d{2})(&amp;lt;minor3&amp;gt;\d{3})\""  
|eval Version=major.".".minor1.".".minor2.".".minor3 
|eval Version=replace(Version,"0","")
|table Version
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 May 2016 16:42:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253612#M75905</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-05-18T16:42:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to use eval to change a field's value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253613#M75906</link>
      <description>&lt;P&gt;yes but how can i do it without the 0 in the second part? i have it like this:&lt;/P&gt;

&lt;P&gt;Version&lt;BR /&gt;
30201425 OR 3.02.01.425&lt;BR /&gt;
30201424 OR 3.02.01.424&lt;/P&gt;

&lt;P&gt;just need the 3.2.1.425&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2016 17:05:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253613#M75906</guid>
      <dc:creator>guillecasco</dc:creator>
      <dc:date>2016-05-18T17:05:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to use eval to change a field's value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253614#M75907</link>
      <description>&lt;P&gt;sorry i missunderstood, it´s working now, thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2016 18:12:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253614#M75907</guid>
      <dc:creator>guillecasco</dc:creator>
      <dc:date>2016-05-18T18:12:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to use eval to change a field's value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253615#M75908</link>
      <description>&lt;P&gt;how about the other way round? &lt;/P&gt;

&lt;P&gt;version&lt;BR /&gt;
1.2.3&lt;/P&gt;

&lt;P&gt;to&lt;/P&gt;

&lt;P&gt;version&lt;BR /&gt;
1.2.3 or 10203&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2016 19:43:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253615#M75908</guid>
      <dc:creator>guillecasco</dc:creator>
      <dc:date>2016-05-18T19:43:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to use eval to change a field's value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253616#M75909</link>
      <description>&lt;P&gt;If you want both formats, try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval version=version." OR ".replace(version, "\.", "0")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 May 2016 21:16:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253616#M75909</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-05-18T21:16:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to use eval to change a field's value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253617#M75910</link>
      <description>&lt;P&gt;Regex: group name must start with a non-digit...&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2016 23:30:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253617#M75910</guid>
      <dc:creator>nawazns5038</dc:creator>
      <dc:date>2016-12-20T23:30:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to use eval to change a field's value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253618#M75911</link>
      <description>&lt;P&gt;eval version2=replace(version,"0",".") | eval new_version= version+" or "+ version2 | rename new_version AS version.&lt;/P&gt;

&lt;P&gt;This avoids confusion between field names . &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:09:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253618#M75911</guid>
      <dc:creator>nawazns5038</dc:creator>
      <dc:date>2020-09-29T12:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to use eval to change a field's value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253619#M75912</link>
      <description>&lt;P&gt;is there anyway to replace all non alphanumeric with a value?&lt;/P&gt;</description>
      <pubDate>Thu, 13 Apr 2017 14:52:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253619#M75912</guid>
      <dc:creator>robertlynch2020</dc:creator>
      <dc:date>2017-04-13T14:52:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to use eval to change a field's value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253620#M75913</link>
      <description>&lt;P&gt;What is your use-case? Can you provide some sample of current and expected values?&lt;/P&gt;</description>
      <pubDate>Thu, 13 Apr 2017 15:01:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253620#M75913</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-04-13T15:01:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to use eval to change a field's value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253621#M75914</link>
      <description>&lt;P&gt;Use this regex for the match&lt;/P&gt;

&lt;P&gt;\W&lt;/P&gt;

&lt;P&gt;Only it will match underscore too.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Apr 2017 15:35:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253621#M75914</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2017-04-13T15:35:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to use eval to change a field's value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253622#M75915</link>
      <description>&lt;P&gt;Thanks for your help&lt;/P&gt;

&lt;P&gt;In Datamodels, i am trying to change the data i am reading in to have only alphanumeric &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;What i have&lt;/STRONG&gt;&lt;BR /&gt;
peter hi&lt;BR /&gt;
ex⁢&lt;BR /&gt;
field=1;like&amp;amp;&lt;BR /&gt;
name&lt;BR /&gt;
john&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;What i want&lt;/STRONG&gt;&lt;BR /&gt;
peterhi&lt;BR /&gt;
exit&lt;BR /&gt;
field1like&lt;BR /&gt;
name&lt;BR /&gt;
john&lt;/P&gt;

&lt;P&gt;so i have been trying the following and it working for one, but i want one command for all non alphanumeric.&lt;BR /&gt;
replace(Context,";","")&lt;BR /&gt;
replace(Context,"=","")&lt;BR /&gt;
replace(Context," ","")&lt;BR /&gt;
replace(Context,"&amp;amp;","")&lt;/P&gt;</description>
      <pubDate>Thu, 13 Apr 2017 16:46:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253622#M75915</guid>
      <dc:creator>robertlynch2020</dc:creator>
      <dc:date>2017-04-13T16:46:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to use eval to change a field's value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253623#M75916</link>
      <description>&lt;P&gt;Just use \W instead of each non-alphanumeric character you're currently using.&lt;/P&gt;

&lt;P&gt;replace(Context,"\W","")&lt;/P&gt;</description>
      <pubDate>Thu, 13 Apr 2017 17:20:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253623#M75916</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2017-04-13T17:20:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to use eval to change a field's value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253624#M75917</link>
      <description>&lt;P&gt;This worked, thanks :).&lt;/P&gt;

&lt;P&gt;However i have another issues where i am trying to do the same thing in props.conf&lt;BR /&gt;
However i cant seem to get the REG to work &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?P&amp;lt;Elapsed&amp;gt;\w+)|
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The idea is to change the Data at the initial point.&lt;/P&gt;

&lt;P&gt;any help would be great &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;So the data is&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;20151029|12:31:00|MUREXFO   |     1 |SessionCreate                 |MXDIS..&amp;amp;PATCHER                  |   0.21s|   0.22s|100%|  -0.01s|   0% |                                      |1065.44Mb
20151029|12:31:00|MUREXFO   |     2 |RequestDocument3              |MXD~'##ISPATCHER                  |   0.01s|   0.03s|100%|  -0.02s|   0% |                                      |1065.65Mb
20151029|12:31:00|MUREXFO   |     3 |RequestDocument3              |MXDISP..??ATCHER                  |   0.01s|   0.01s|100%|   0.00s|   0% |       
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The code i have is &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;^(?:[^\|\n]*\|){5}(?P&amp;lt;Command&amp;gt;\w+)| *-*(?P&amp;lt;Elapsed2&amp;gt;\d+\.\d+)\w+\| *-*(?P&amp;lt;CPU&amp;gt;\d+\.\d+)s\| *-*(?P&amp;lt;CPU_PER&amp;gt;\d+)%\| *-*(?P&amp;lt;RDB_COM&amp;gt;\d+\.\d+)s\| *-*(?P&amp;lt;RDB_COM_PER&amp;gt;\d+)%\s+\|
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The issues is i am only getting the first few characters, and i want all alpha-numeric the pipe |&lt;/P&gt;

&lt;P&gt;So i have&lt;BR /&gt;
MXDIS..&amp;amp;PATCHER&lt;BR /&gt;
MXD~'##ISPATCHER&lt;BR /&gt;
MXDISP..??ATCHER &lt;/P&gt;

&lt;P&gt;I want&lt;BR /&gt;
MXDISPATCHER&lt;BR /&gt;
MXDISPATCHER&lt;BR /&gt;
MXDISPATCHER &lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2017 11:26:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-eval-to-change-a-field-s-value/m-p/253624#M75917</guid>
      <dc:creator>robertlynch2020</dc:creator>
      <dc:date>2017-04-14T11:26:06Z</dc:date>
    </item>
  </channel>
</rss>

