<?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: SPL: Use regex replacement string multiple times in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/SPL-Use-regex-replacement-string-multiple-times/m-p/572848#M199642</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;thank you very much for the quick answer, which helped a lot. We need to do the transformation&amp;nbsp;for multiple fields within a complex query. Therefore, the solution had to be adapted somewhat:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval fieldname1="1;A__B
2;B__C__D__A__E
3;G"
| eval other_fields_1="other_content"

| eval tmp_raw = _raw
| eval _raw=fieldname1 ``` temporarily overwriting _raw with the field value ```
| multikv noheader=t
| table _raw *other_fields* ``` to keep the fields which we still need ```
| eval first=mvindex(split(_raw,";"),0)
| eval second=split(mvindex(split(_raw,";"),1),"__")
| mvexpand second
| eval _raw=first.";".second
| rename _raw as fieldname1
| fields  - first,second
| mvcombine delim="\n" fieldname1 ``` to get a multivalue field ```
| eval _raw = tmp_raw
| table *&lt;/LI-CODE&gt;&lt;P&gt;Is there a better solution than overwriting _raw with the field value? I also was surprised that creating a multikv.conf file seems not to be required, as it autodetects semicolon as the separator and ignores the underlines.&lt;/P&gt;</description>
    <pubDate>Thu, 28 Oct 2021 16:03:29 GMT</pubDate>
    <dc:creator>_Tom</dc:creator>
    <dc:date>2021-10-28T16:03:29Z</dc:date>
    <item>
      <title>SPL: Use regex replacement string multiple times</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SPL-Use-regex-replacement-string-multiple-times/m-p/572605#M199575</link>
      <description>&lt;P&gt;Hello *,&lt;BR /&gt;&lt;BR /&gt;I am looking for an SPL that reads the first part of a string via regex and replaces all occurrences of a certain character with this first part. This is to be used for summary indexing.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;1;A__B
2;B__C__D__A__E
3;G&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;is to be transformed into (each line will become a value in a multivalue field):&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;1;A
1;B
2;B
2;C
2;D
2;A
2;E
3;G&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Neither replace nor rex seem to be able to afford multiple replacements of this kind. I also tried foreach with some field extractions but failed. Before I write a custom search command for it, I hope for your ideas to solve the problem with some clever standard SPL.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance for your thoughts!&lt;/P&gt;</description>
      <pubDate>Wed, 27 Oct 2021 08:57:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SPL-Use-regex-replacement-string-multiple-times/m-p/572605#M199575</guid>
      <dc:creator>_Tom</dc:creator>
      <dc:date>2021-10-27T08:57:57Z</dc:date>
    </item>
    <item>
      <title>Re: SPL: Use regex replacement string multiple times</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SPL-Use-regex-replacement-string-multiple-times/m-p/572606#M199576</link>
      <description>&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw="1;A__B
2;B__C__D__A__E
3;G"
| multikv noheader=t
| table _raw




| eval first=mvindex(split(_raw,";"),0)
| eval second=split(mvindex(split(_raw,";"),1),"_")
| mvexpand second
| where second!=""
| eval _raw=first.";".second&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 27 Oct 2021 09:11:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SPL-Use-regex-replacement-string-multiple-times/m-p/572606#M199576</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-10-27T09:11:05Z</dc:date>
    </item>
    <item>
      <title>Re: SPL: Use regex replacement string multiple times</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SPL-Use-regex-replacement-string-multiple-times/m-p/572848#M199642</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;thank you very much for the quick answer, which helped a lot. We need to do the transformation&amp;nbsp;for multiple fields within a complex query. Therefore, the solution had to be adapted somewhat:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval fieldname1="1;A__B
2;B__C__D__A__E
3;G"
| eval other_fields_1="other_content"

| eval tmp_raw = _raw
| eval _raw=fieldname1 ``` temporarily overwriting _raw with the field value ```
| multikv noheader=t
| table _raw *other_fields* ``` to keep the fields which we still need ```
| eval first=mvindex(split(_raw,";"),0)
| eval second=split(mvindex(split(_raw,";"),1),"__")
| mvexpand second
| eval _raw=first.";".second
| rename _raw as fieldname1
| fields  - first,second
| mvcombine delim="\n" fieldname1 ``` to get a multivalue field ```
| eval _raw = tmp_raw
| table *&lt;/LI-CODE&gt;&lt;P&gt;Is there a better solution than overwriting _raw with the field value? I also was surprised that creating a multikv.conf file seems not to be required, as it autodetects semicolon as the separator and ignores the underlines.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Oct 2021 16:03:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SPL-Use-regex-replacement-string-multiple-times/m-p/572848#M199642</guid>
      <dc:creator>_Tom</dc:creator>
      <dc:date>2021-10-28T16:03:29Z</dc:date>
    </item>
    <item>
      <title>Re: SPL: Use regex replacement string multiple times</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SPL-Use-regex-replacement-string-multiple-times/m-p/572934#M199680</link>
      <description>&lt;P&gt;You could try rename _raw as tmp_raw and fieldname1 as _raw rather the two assignments but, this is as good a way as any to get multikv to work.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Oct 2021 11:31:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SPL-Use-regex-replacement-string-multiple-times/m-p/572934#M199680</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-10-29T11:31:09Z</dc:date>
    </item>
  </channel>
</rss>

