<?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 regex to replace string? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-replace-string/m-p/453388#M128330</link>
    <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... rex field=url mode=sed "s%/interactions/.*/result_data%/interactions/result_data%"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 13 May 2019 02:58:05 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2019-05-13T02:58:05Z</dc:date>
    <item>
      <title>How to use regex to replace string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-replace-string/m-p/453385#M128327</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;I have the below urls. How can I use the regex to remove the tokens from urls? Looking to remove data between /interactions/ and result_data.&lt;/P&gt;

&lt;P&gt;sample:&lt;BR /&gt;
&lt;A href="https://test.com:443/test11/interactions/000e433c-a27-344347f-drfere/result_data"&gt;https://test.com:443/test11/interactions/000e433c-a27-344347f-drfere/result_data&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;output needed:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://test.com:443/test11/interactions/result_data"&gt;https://test.com:443/test11/interactions/result_data&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 May 2019 00:12:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-replace-string/m-p/453385#M128327</guid>
      <dc:creator>knalla</dc:creator>
      <dc:date>2019-05-13T00:12:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to use regex to replace string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-replace-string/m-p/453386#M128328</link>
      <description>&lt;P&gt;Are you looking to replace this as search time?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex field=url "^(?&amp;lt;part1&amp;gt;.*/interactions)/.*/(?&amp;lt;part2&amp;gt;result_data)$" | eval url=part1."/".part2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you are looking to do this at index time, you will need to use &lt;CODE&gt;SEDCMD&lt;/CODE&gt; or transforms to replace the token (&lt;A href="https://docs.splunk.com/Documentation/Splunk/7.2.6/Data/Anonymizedata"&gt;https://docs.splunk.com/Documentation/Splunk/7.2.6/Data/Anonymizedata&lt;/A&gt; ).&lt;BR /&gt;
In props.conf,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;SEDCMD-remove_tokens = s/interactions\/.*\/result-data/interactions\/result-data
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 May 2019 01:09:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-replace-string/m-p/453386#M128328</guid>
      <dc:creator>sduff_splunk</dc:creator>
      <dc:date>2019-05-13T01:09:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to use regex to replace string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-replace-string/m-p/453387#M128329</link>
      <description>&lt;P&gt;Similar to what sduff wrote but more generalized to just remove everything between the last slashes (/)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=url "(?&amp;lt;part1&amp;gt;.+\/).+\/(?&amp;lt;part2&amp;gt;.+)"
| eval url=part1+part2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 May 2019 02:06:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-replace-string/m-p/453387#M128329</guid>
      <dc:creator>burwell</dc:creator>
      <dc:date>2019-05-13T02:06:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to use regex to replace string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-replace-string/m-p/453388#M128330</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... rex field=url mode=sed "s%/interactions/.*/result_data%/interactions/result_data%"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 May 2019 02:58:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-replace-string/m-p/453388#M128330</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-05-13T02:58:05Z</dc:date>
    </item>
  </channel>
</rss>

