<?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 you help me extract and replace a new field from present field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-extract-and-replace-a-new-field-from-present/m-p/456374#M129013</link>
    <description>&lt;P&gt;I have one field named as "&lt;STRONG&gt;data1&lt;/STRONG&gt;" and I need to create another field named as "&lt;STRONG&gt;data2&lt;/STRONG&gt;". In this new field, I need to copy same value of "data1" field, if value starts with "0" , and if value is not starting with "0" , then i want to add the 0 in the beginning of the value.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Original field&lt;/STRONG&gt;&lt;BR /&gt;
data1=0975665&lt;BR /&gt;
data1=&lt;EM&gt;976554&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;New field&lt;/STRONG&gt;&lt;BR /&gt;
data2=0975665&lt;BR /&gt;
Data2=&lt;EM&gt;0976554&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;Please help me to achieve this.&lt;/P&gt;</description>
    <pubDate>Wed, 12 Sep 2018 12:05:25 GMT</pubDate>
    <dc:creator>mustafag</dc:creator>
    <dc:date>2018-09-12T12:05:25Z</dc:date>
    <item>
      <title>Can you help me extract and replace a new field from present field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-extract-and-replace-a-new-field-from-present/m-p/456374#M129013</link>
      <description>&lt;P&gt;I have one field named as "&lt;STRONG&gt;data1&lt;/STRONG&gt;" and I need to create another field named as "&lt;STRONG&gt;data2&lt;/STRONG&gt;". In this new field, I need to copy same value of "data1" field, if value starts with "0" , and if value is not starting with "0" , then i want to add the 0 in the beginning of the value.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Original field&lt;/STRONG&gt;&lt;BR /&gt;
data1=0975665&lt;BR /&gt;
data1=&lt;EM&gt;976554&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;New field&lt;/STRONG&gt;&lt;BR /&gt;
data2=0975665&lt;BR /&gt;
Data2=&lt;EM&gt;0976554&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;Please help me to achieve this.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Sep 2018 12:05:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-extract-and-replace-a-new-field-from-present/m-p/456374#M129013</guid>
      <dc:creator>mustafag</dc:creator>
      <dc:date>2018-09-12T12:05:25Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me extract and replace a new field from present field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-extract-and-replace-a-new-field-from-present/m-p/456375#M129014</link>
      <description>&lt;P&gt;@mustafag&lt;/P&gt;

&lt;P&gt;Can you please try below search?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;YOUR_SEARCH | eval data2=if(substr(data1,1,1)=="0",data1,"0".data1)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;My Sample Search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval data1="0975665" | append [| makeresults | eval data1="976554"] | eval data2=if(substr(data1,1,1)=="0",data1,"0".data1)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 12 Sep 2018 12:14:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-extract-and-replace-a-new-field-from-present/m-p/456375#M129014</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2018-09-12T12:14:33Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me extract and replace a new field from present field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-extract-and-replace-a-new-field-from-present/m-p/456376#M129015</link>
      <description>&lt;P&gt;Hi Kamlesh,&lt;BR /&gt;
  Appreciate for the quick response. your advised query did work as expected but I also want to validate the length of the field in addition to above requirement. So if field length is 7 then no need to replace, only replace if the length is 6.&lt;/P&gt;

&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Wed, 12 Sep 2018 12:21:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-extract-and-replace-a-new-field-from-present/m-p/456376#M129015</guid>
      <dc:creator>mustafag</dc:creator>
      <dc:date>2018-09-12T12:21:13Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me extract and replace a new field from present field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-extract-and-replace-a-new-field-from-present/m-p/456377#M129016</link>
      <description>&lt;P&gt;@mustafag&lt;/P&gt;

&lt;P&gt;Please use below search.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;YOUR_SEARCH | eval data2=if(substr(data1,1,1)=="0",data1,if(len(data1)==7,data1, "0".data1))
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Sep 2018 12:26:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-extract-and-replace-a-new-field-from-present/m-p/456377#M129016</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2018-09-12T12:26:47Z</dc:date>
    </item>
  </channel>
</rss>

