<?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 First Two Digits in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Replace-First-Two-Digits/m-p/311370#M93324</link>
    <description>&lt;P&gt;Hi @cusello, thank you for the comprehensive reply.&lt;/P&gt;

&lt;P&gt;I want to make the change at search time, so I used the second solution you provided but unfortunately, it didn't work with the output of the field now showing: &lt;/P&gt;

&lt;P&gt;0\d*&lt;/P&gt;

&lt;P&gt;Many thanks and kind regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
    <pubDate>Thu, 31 Aug 2017 11:57:42 GMT</pubDate>
    <dc:creator>IRHM73</dc:creator>
    <dc:date>2017-08-31T11:57:42Z</dc:date>
    <item>
      <title>Replace First Two Digits</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-First-Two-Digits/m-p/311368#M93322</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I wonder whether someone may be able to help me please.&lt;/P&gt;

&lt;P&gt;I have a telephone number field "telnofac" with the first two digits being 44.&lt;/P&gt;

&lt;P&gt;Could someone tell me please is there a way to replace these the 44 with a 0?&lt;/P&gt;

&lt;P&gt;Many thanks and kind regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2017 11:25:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-First-Two-Digits/m-p/311368#M93322</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2017-08-31T11:25:56Z</dc:date>
    </item>
    <item>
      <title>Re: Replace First Two Digits</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-First-Two-Digits/m-p/311369#M93323</link>
      <description>&lt;P&gt;Hi IRHM73,&lt;BR /&gt;
two additional information:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;do you want to replace numbers at index time or at search time?&lt;/LI&gt;
&lt;LI&gt;do you want replace 44 with 0 or with 044?&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;if at index time and you want to replace 44 with 0, you have to insert in your props.conf in your sourcetype stanza (if before number there's "telnofac=")&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;SEDCMD-telnofac = s/telnofac\=44\d*/telnofac\=0\d*/g
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(check regex!)&lt;/P&gt;

&lt;P&gt;if you want to do this at search time and replace 44 with 0 use this command&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=telnofac mode=sed "s/44\d*/0\d*/g"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval telnofac = replace(telnofac , "44\d*","0\d*")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2017 11:39:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-First-Two-Digits/m-p/311369#M93323</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-08-31T11:39:18Z</dc:date>
    </item>
    <item>
      <title>Re: Replace First Two Digits</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-First-Two-Digits/m-p/311370#M93324</link>
      <description>&lt;P&gt;Hi @cusello, thank you for the comprehensive reply.&lt;/P&gt;

&lt;P&gt;I want to make the change at search time, so I used the second solution you provided but unfortunately, it didn't work with the output of the field now showing: &lt;/P&gt;

&lt;P&gt;0\d*&lt;/P&gt;

&lt;P&gt;Many thanks and kind regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2017 11:57:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-First-Two-Digits/m-p/311370#M93324</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2017-08-31T11:57:42Z</dc:date>
    </item>
    <item>
      <title>Re: Replace First Two Digits</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-First-Two-Digits/m-p/311371#M93325</link>
      <description>&lt;P&gt;try with&lt;BR /&gt;
| replace "44*" WITH "0*" IN telnofac &lt;BR /&gt;
instead rex command&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:34:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-First-Two-Digits/m-p/311371#M93325</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-09-29T15:34:24Z</dc:date>
    </item>
    <item>
      <title>Re: Replace First Two Digits</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-First-Two-Digits/m-p/311372#M93326</link>
      <description>&lt;P&gt;Thank you @cusello&lt;/P&gt;

&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2017 12:15:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-First-Two-Digits/m-p/311372#M93326</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2017-08-31T12:15:11Z</dc:date>
    </item>
    <item>
      <title>Re: Replace First Two Digits</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-First-Two-Digits/m-p/311373#M93327</link>
      <description>&lt;P&gt;Hi @cusello and all.&lt;/P&gt;

&lt;P&gt;I was able to make a working solution using: sed "s/44/0/g"&lt;/P&gt;

&lt;P&gt;Many thanks and kind regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2017 12:22:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-First-Two-Digits/m-p/311373#M93327</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2017-08-31T12:22:58Z</dc:date>
    </item>
    <item>
      <title>Re: Replace First Two Digits</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-First-Two-Digits/m-p/311374#M93328</link>
      <description>&lt;P&gt;Chris, you are aware that this will change all occurrences of 44 with 0, so if your telnofac is 4412345446789, it will result in 01234506789; probably not what you want.&lt;/P&gt;

&lt;P&gt;I would change it to &lt;CODE&gt;| rex field=telnofac mode=sed "s/^44/0/"&lt;/CODE&gt; to only replace the first occurrence, anchored to the beginning of the field, just to be safe.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2017 17:35:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-First-Two-Digits/m-p/311374#M93328</guid>
      <dc:creator>s2_splunk</dc:creator>
      <dc:date>2017-08-31T17:35:32Z</dc:date>
    </item>
    <item>
      <title>Re: Replace First Two Digits</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-First-Two-Digits/m-p/311375#M93329</link>
      <description>&lt;P&gt;Hi @ssievert, that's great I hadn't realise that.&lt;/P&gt;

&lt;P&gt;Thank you for taking the time to reply.&lt;/P&gt;

&lt;P&gt;May I ask what the ^ does.&lt;/P&gt;

&lt;P&gt;Many thanks and kind regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2017 05:44:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-First-Two-Digits/m-p/311375#M93329</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2017-09-01T05:44:47Z</dc:date>
    </item>
    <item>
      <title>Re: Replace First Two Digits</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-First-Two-Digits/m-p/311376#M93330</link>
      <description>&lt;P&gt;"^" anchors to the beginning of the string. See &lt;A href="http://www.regular-expressions.info/anchors.html"&gt;here&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2017 21:21:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-First-Two-Digits/m-p/311376#M93330</guid>
      <dc:creator>s2_splunk</dc:creator>
      <dc:date>2017-09-01T21:21:07Z</dc:date>
    </item>
    <item>
      <title>Re: Replace First Two Digits</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-First-Two-Digits/m-p/311377#M93331</link>
      <description>&lt;P&gt;Many thanks @ssievert.&lt;/P&gt;

&lt;P&gt;Regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Mon, 04 Sep 2017 05:37:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-First-Two-Digits/m-p/311377#M93331</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2017-09-04T05:37:20Z</dc:date>
    </item>
  </channel>
</rss>

