<?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 Regex - match all ocurances of a character in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regex-match-all-ocurances-of-a-character/m-p/40721#M9399</link>
    <description>&lt;P&gt;Hi guys,&lt;/P&gt;

&lt;P&gt;I have been playing around trying to match multiple ocurances of a pattern and replace it with a regex in transforms.conf.&lt;/P&gt;

&lt;P&gt;sample data&lt;BR /&gt;
&lt;A href="mailto:Kenan-xMuharemagic-x-xkenan@neseco.ba-x-x"&gt;Kenan-xMuharemagic-x-xkenan@neseco.ba-x-x&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I am trying to match the pattern "-x" and replace it with "_". It works perfect for one match but for the rest of the matches in the event it doesnt. This is not a multiline event and the characters I wish to replace may appear multiple times even in a single word.&lt;/P&gt;

&lt;P&gt;Desired Result&lt;BR /&gt;
Kenan_ Muharemagic_ _ &lt;A href="mailto:kenan@neseco.ba_"&gt;kenan@neseco.ba_&lt;/A&gt; _ (excuse the " " at _)&lt;/P&gt;

&lt;P&gt;I was able to do this earlier with the max_matches parameter during search time. This time I am trying to replace these characters before indexing, like when anonimyzing CC numbers or so...&lt;/P&gt;

&lt;P&gt;Is there a way to tell splunk to replace all matches of a pattern in transforms.conf?&lt;/P&gt;</description>
    <pubDate>Fri, 22 Feb 2013 16:45:22 GMT</pubDate>
    <dc:creator>kenchisho</dc:creator>
    <dc:date>2013-02-22T16:45:22Z</dc:date>
    <item>
      <title>Regex - match all ocurances of a character</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-match-all-ocurances-of-a-character/m-p/40721#M9399</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;

&lt;P&gt;I have been playing around trying to match multiple ocurances of a pattern and replace it with a regex in transforms.conf.&lt;/P&gt;

&lt;P&gt;sample data&lt;BR /&gt;
&lt;A href="mailto:Kenan-xMuharemagic-x-xkenan@neseco.ba-x-x"&gt;Kenan-xMuharemagic-x-xkenan@neseco.ba-x-x&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I am trying to match the pattern "-x" and replace it with "_". It works perfect for one match but for the rest of the matches in the event it doesnt. This is not a multiline event and the characters I wish to replace may appear multiple times even in a single word.&lt;/P&gt;

&lt;P&gt;Desired Result&lt;BR /&gt;
Kenan_ Muharemagic_ _ &lt;A href="mailto:kenan@neseco.ba_"&gt;kenan@neseco.ba_&lt;/A&gt; _ (excuse the " " at _)&lt;/P&gt;

&lt;P&gt;I was able to do this earlier with the max_matches parameter during search time. This time I am trying to replace these characters before indexing, like when anonimyzing CC numbers or so...&lt;/P&gt;

&lt;P&gt;Is there a way to tell splunk to replace all matches of a pattern in transforms.conf?&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2013 16:45:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-match-all-ocurances-of-a-character/m-p/40721#M9399</guid>
      <dc:creator>kenchisho</dc:creator>
      <dc:date>2013-02-22T16:45:22Z</dc:date>
    </item>
    <item>
      <title>Re: Regex - match all ocurances of a character</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-match-all-ocurances-of-a-character/m-p/40722#M9400</link>
      <description>&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Data/Anonymizedatausingconfigurationfiles"&gt;anonymizing data&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;look at the SEDCMD section, and the "global" /g flag&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2013 18:14:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-match-all-ocurances-of-a-character/m-p/40722#M9400</guid>
      <dc:creator>jonuwz</dc:creator>
      <dc:date>2013-02-22T18:14:57Z</dc:date>
    </item>
    <item>
      <title>Re: Regex - match all ocurances of a character</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-match-all-ocurances-of-a-character/m-p/40723#M9401</link>
      <description>&lt;P&gt;I'v already tried that. Been playing with this all day.&lt;/P&gt;

&lt;P&gt;The case is that I am indexing a binary encoded log file... Splunk indexes all ASCII characters without a problem... but there are a few non-ASCII characters that are indexed as "\x6\xD1" which would be "Đ".&lt;/P&gt;

&lt;P&gt;I've tried modifying the CHARSET but the only one that works is CP852, which is sadly not supported by Splunk.&lt;/P&gt;

&lt;P&gt;As for SED I have not been able to match the pattern with a sed regex within Splunk, however when using standalone Regex tools or OSX CLI sed I match and replace the patterns without problems...&lt;/P&gt;

&lt;P&gt;I have managed to work this out using transforms.conf with a regex and then applying that in props multiple times (ex. 10 times for a possibe 10 repetitions of the same character in 1 event). This is a very ugly workaround and I will try to find another way.&lt;/P&gt;

&lt;P&gt;Example:&lt;/P&gt;

&lt;P&gt;raw data: &lt;CODE&gt;\x6\xD1\x6\xD1\x6\xD1\x6\xD1\x6\xD1&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;transforms.conf

[bin2text]
REGEX = (?)(.*)\x6\\xD1(.*)
FORMAT = $1Đ$2

props.conf
[sourcetype]
TRANSFORM-test = bin2text, bin2text, bin2text, bin2text, bin2text
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;result data: ĐĐĐĐĐ&lt;/P&gt;

&lt;P&gt;As I said a very ugly solution but the only one I got working. I'm open to suggestions if someone has an idea...&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2013 21:46:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-match-all-ocurances-of-a-character/m-p/40723#M9401</guid>
      <dc:creator>kenchisho</dc:creator>
      <dc:date>2013-02-22T21:46:00Z</dc:date>
    </item>
  </channel>
</rss>

