<?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 edit my regex to replace a number 0-9? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-regex-to-replace-a-number-0-9/m-p/314958#M94295</link>
    <description>&lt;P&gt;OK, I updated my answer to accommodate your replacement strings; try it now.&lt;/P&gt;</description>
    <pubDate>Fri, 26 May 2017 17:07:02 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2017-05-26T17:07:02Z</dc:date>
    <item>
      <title>How to edit my regex to replace a number 0-9?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-regex-to-replace-a-number-0-9/m-p/314949#M94286</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;

&lt;P&gt;I have requirement, where I need to replace a series of numbers with something like this &lt;CODE&gt;a/b/c/123456&lt;/CODE&gt; with &lt;CODE&gt;a/b/c{Id}&lt;/CODE&gt;. &lt;/P&gt;

&lt;P&gt;When I use regex and use &lt;CODE&gt;\d&lt;/CODE&gt; its replacing each and every decimal number with &lt;CODE&gt;{Id}&lt;/CODE&gt; something like this  &lt;CODE&gt;a/b/c/{Id}{Id}{Id}{Id}{Id}{Id}&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;I want something like &lt;CODE&gt;a/b/c{Id}&lt;/CODE&gt;, can you let me know how this can be achieved.&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2017 19:07:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-regex-to-replace-a-number-0-9/m-p/314949#M94286</guid>
      <dc:creator>smaran06</dc:creator>
      <dc:date>2017-05-22T19:07:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my regex to replace a number 0-9?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-regex-to-replace-a-number-0-9/m-p/314950#M94287</link>
      <description>&lt;P&gt;Try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | rex mode=sed field=yourfield "s/(\d+)/{Id}/"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OR&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | eval yourfield=replace(yourfield,"(\d+)","{Id}")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 May 2017 19:41:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-regex-to-replace-a-number-0-9/m-p/314950#M94287</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-05-22T19:41:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my regex to replace a number 0-9?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-regex-to-replace-a-number-0-9/m-p/314951#M94288</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults | eval raw="a/b/c/1234567"

| rename COMMENT AS "Everything above fakes your data; everything below is your solution"

| rex field=raw mode=sed "s%a/b/c/\\d+%a/b/c/{ld}%"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 May 2017 21:12:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-regex-to-replace-a-number-0-9/m-p/314951#M94288</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-05-22T21:12:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my regex to replace a number 0-9?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-regex-to-replace-a-number-0-9/m-p/314952#M94289</link>
      <description>&lt;P&gt;Thanks, this works, can you please let me know, if we need to replace all such formats like below.&lt;/P&gt;

&lt;P&gt;a/b/c/464646/d/e/242442424&lt;/P&gt;

&lt;P&gt;I want output like this &lt;/P&gt;

&lt;P&gt;a/b/c/{Id1}/d/e/{Id2}&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2017 23:51:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-regex-to-replace-a-number-0-9/m-p/314952#M94289</guid>
      <dc:creator>smaran06</dc:creator>
      <dc:date>2017-05-22T23:51:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my regex to replace a number 0-9?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-regex-to-replace-a-number-0-9/m-p/314953#M94290</link>
      <description>&lt;P&gt;You really should be clear from the get-go.  This is a very different request.&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 00:03:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-regex-to-replace-a-number-0-9/m-p/314953#M94290</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-05-23T00:03:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my regex to replace a number 0-9?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-regex-to-replace-a-number-0-9/m-p/314954#M94291</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults | eval raw="a/b/c/464646/d/e/242442424"

| rename COMMENT AS "Everything above fakes your data; everything below is your solution"

| rex field=raw mode=sed "s%/\d+/%/536RTYWW876Y788U998/% ... s%/\d+/%/536RTYWW876Y788U998/%"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Replace &lt;CODE&gt;...&lt;/CODE&gt; with as many additional iterations as you need of the &lt;CODE&gt;sed&lt;/CODE&gt; command string.&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 00:10:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-regex-to-replace-a-number-0-9/m-p/314954#M94291</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-05-23T00:10:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my regex to replace a number 0-9?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-regex-to-replace-a-number-0-9/m-p/314955#M94292</link>
      <description>&lt;P&gt;Thanks this is super  helpful, I am able to reduce my spunk query to  lot better state.&lt;/P&gt;

&lt;P&gt;One  last question how this can be achived  in case of Alpha Numeric.&lt;/P&gt;

&lt;P&gt;I tried something like this.&lt;/P&gt;

&lt;P&gt;|rex field=Path mode=sed "s/\w+\d+/{Id}/"  &lt;/P&gt;

&lt;P&gt;It didn't, help me, please let me know, if I am doing anything wrong here &lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2017 21:03:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-regex-to-replace-a-number-0-9/m-p/314955#M94292</guid>
      <dc:creator>smaran06</dc:creator>
      <dc:date>2017-05-24T21:03:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my regex to replace a number 0-9?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-regex-to-replace-a-number-0-9/m-p/314956#M94293</link>
      <description>&lt;P&gt;So you are saying that your &lt;CODE&gt;{Id}&lt;/CODE&gt; strings do contain numbers/digits?  If so, is it really surrounded by the literal curly-brace characters &lt;CODE&gt;{&lt;/CODE&gt; and &lt;CODE&gt;}&lt;/CODE&gt; (that will make the modified solution easier)?&lt;/P&gt;</description>
      <pubDate>Thu, 25 May 2017 20:29:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-regex-to-replace-a-number-0-9/m-p/314956#M94293</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-05-25T20:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my regex to replace a number 0-9?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-regex-to-replace-a-number-0-9/m-p/314957#M94294</link>
      <description>&lt;P&gt;actually my string won't contain any curly braces, it looks like this.&lt;/P&gt;

&lt;P&gt;536RTYWW876Y788U998&lt;/P&gt;</description>
      <pubDate>Fri, 26 May 2017 06:07:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-regex-to-replace-a-number-0-9/m-p/314957#M94294</guid>
      <dc:creator>smaran06</dc:creator>
      <dc:date>2017-05-26T06:07:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my regex to replace a number 0-9?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-regex-to-replace-a-number-0-9/m-p/314958#M94295</link>
      <description>&lt;P&gt;OK, I updated my answer to accommodate your replacement strings; try it now.&lt;/P&gt;</description>
      <pubDate>Fri, 26 May 2017 17:07:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-regex-to-replace-a-number-0-9/m-p/314958#M94295</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-05-26T17:07:02Z</dc:date>
    </item>
  </channel>
</rss>

