<?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 How to replace string using rex with partial matched string? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-replace-string-using-rex-with-partial-matched-string/m-p/658314#M227399</link>
    <description>&lt;P&gt;How to replace string using rex with partial matched string?&lt;BR /&gt;Thank you for your help.&lt;BR /&gt;For example:&lt;BR /&gt;I tried to replace "::" (double colon) with ":0:"&amp;nbsp; (colon zero colon) if it the previous characters contain ":" followed by "1 to 3 characters"&amp;nbsp;&lt;BR /&gt;| rex mode=sed field=ip "s/:.{1,3}::/:.{1,3}:0:/g"&amp;nbsp; &amp;nbsp;=&amp;gt; this does not work because it will literally replace it with&lt;BR /&gt;":.{1,3}:0:"&amp;nbsp; &amp;nbsp;instead of retaining the matched strings&lt;BR /&gt;&lt;BR /&gt;Before&lt;BR /&gt;a0:1&lt;STRONG&gt;::&lt;/STRONG&gt;21&lt;BR /&gt;b0:1c&lt;STRONG&gt;::&lt;/STRONG&gt;21&lt;BR /&gt;c0:a13&lt;STRONG&gt;::&lt;/STRONG&gt;23&lt;BR /&gt;&lt;BR /&gt;After&lt;BR /&gt;a0:1&lt;STRONG&gt;:0:&lt;/STRONG&gt;21&lt;BR /&gt;b0:11&lt;STRONG&gt;:0:&lt;/STRONG&gt;21&lt;BR /&gt;c0:111&lt;STRONG&gt;:0:&lt;/STRONG&gt;23&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 21 Sep 2023 15:33:46 GMT</pubDate>
    <dc:creator>LearningGuy</dc:creator>
    <dc:date>2023-09-21T15:33:46Z</dc:date>
    <item>
      <title>How to replace string using rex with partial matched string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-replace-string-using-rex-with-partial-matched-string/m-p/658314#M227399</link>
      <description>&lt;P&gt;How to replace string using rex with partial matched string?&lt;BR /&gt;Thank you for your help.&lt;BR /&gt;For example:&lt;BR /&gt;I tried to replace "::" (double colon) with ":0:"&amp;nbsp; (colon zero colon) if it the previous characters contain ":" followed by "1 to 3 characters"&amp;nbsp;&lt;BR /&gt;| rex mode=sed field=ip "s/:.{1,3}::/:.{1,3}:0:/g"&amp;nbsp; &amp;nbsp;=&amp;gt; this does not work because it will literally replace it with&lt;BR /&gt;":.{1,3}:0:"&amp;nbsp; &amp;nbsp;instead of retaining the matched strings&lt;BR /&gt;&lt;BR /&gt;Before&lt;BR /&gt;a0:1&lt;STRONG&gt;::&lt;/STRONG&gt;21&lt;BR /&gt;b0:1c&lt;STRONG&gt;::&lt;/STRONG&gt;21&lt;BR /&gt;c0:a13&lt;STRONG&gt;::&lt;/STRONG&gt;23&lt;BR /&gt;&lt;BR /&gt;After&lt;BR /&gt;a0:1&lt;STRONG&gt;:0:&lt;/STRONG&gt;21&lt;BR /&gt;b0:11&lt;STRONG&gt;:0:&lt;/STRONG&gt;21&lt;BR /&gt;c0:111&lt;STRONG&gt;:0:&lt;/STRONG&gt;23&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2023 15:33:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-replace-string-using-rex-with-partial-matched-string/m-p/658314#M227399</guid>
      <dc:creator>LearningGuy</dc:creator>
      <dc:date>2023-09-21T15:33:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace string using rex with partial matched string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-replace-string-using-rex-with-partial-matched-string/m-p/658316#M227401</link>
      <description>&lt;P&gt;Characters to be retained should be enclosed in a capture group and that group referenced in the replacement text.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex mode=sed field=ip "s/:(.{1,3})::/:\1:0:/g" &lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 21 Sep 2023 15:58:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-replace-string-using-rex-with-partial-matched-string/m-p/658316#M227401</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2023-09-21T15:58:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace string using rex with partial matched string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-replace-string-using-rex-with-partial-matched-string/m-p/658344#M227409</link>
      <description>&lt;P&gt;It worked!!&amp;nbsp; Thank you..&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2023 19:58:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-replace-string-using-rex-with-partial-matched-string/m-p/658344#M227409</guid>
      <dc:creator>LearningGuy</dc:creator>
      <dc:date>2023-09-21T19:58:15Z</dc:date>
    </item>
  </channel>
</rss>

