<?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 Replace Eval Function using Regex in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Replace-Eval-Function-using-Regex/m-p/691893#M235548</link>
    <description>&lt;P&gt;When using regex how can I take a field formatted as "0012-4250" and only show the 1st and lat 3 digits? I tried the following in which maintains the original output:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| eval AcctCode = replace(AcctCode,"(\d{4}-)(\d{4})","\1\2")&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 27 Jun 2024 21:18:45 GMT</pubDate>
    <dc:creator>Substance82</dc:creator>
    <dc:date>2024-06-27T21:18:45Z</dc:date>
    <item>
      <title>Replace Eval Function using Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-Eval-Function-using-Regex/m-p/691893#M235548</link>
      <description>&lt;P&gt;When using regex how can I take a field formatted as "0012-4250" and only show the 1st and lat 3 digits? I tried the following in which maintains the original output:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| eval AcctCode = replace(AcctCode,"(\d{4}-)(\d{4})","\1\2")&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 27 Jun 2024 21:18:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-Eval-Function-using-Regex/m-p/691893#M235548</guid>
      <dc:creator>Substance82</dc:creator>
      <dc:date>2024-06-27T21:18:45Z</dc:date>
    </item>
    <item>
      <title>Re: Replace Eval Function using Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-Eval-Function-using-Regex/m-p/691894#M235549</link>
      <description>&lt;P&gt;The current regex takes the first 4 digits and the last 4 digits and then puts them back together, which is why the result does not change.&amp;nbsp; Try this, which takes the first and last 3 digits and puts them together.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex field=AcctCode mode=sed "s/(\d{3})\d-\d(\d{3})/\1\2/"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2024 20:31:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-Eval-Function-using-Regex/m-p/691894#M235549</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2024-06-27T20:31:36Z</dc:date>
    </item>
    <item>
      <title>Re: Replace Eval Function using Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-Eval-Function-using-Regex/m-p/691895#M235550</link>
      <description>&lt;P&gt;Hi.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your reply is greatly appreciated, but I must use the eval command to achieve my results. Do you have an eval command solution?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2024 20:35:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-Eval-Function-using-Regex/m-p/691895#M235550</guid>
      <dc:creator>Substance82</dc:creator>
      <dc:date>2024-06-27T20:35:49Z</dc:date>
    </item>
    <item>
      <title>Re: Replace Eval Function using Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-Eval-Function-using-Regex/m-p/691902#M235552</link>
      <description>&lt;P&gt;Nevermind All.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By some miracle I figured it out!&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| eval ProdCode = replace(ProdCode,"^(\d)\d{3}-\d(\d{3})","\1xxx-x\2")&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 27 Jun 2024 23:51:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-Eval-Function-using-Regex/m-p/691902#M235552</guid>
      <dc:creator>Substance82</dc:creator>
      <dc:date>2024-06-27T23:51:37Z</dc:date>
    </item>
  </channel>
</rss>

