<?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: Cannot transform string with regex in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Cannot-transform-string-with-regex/m-p/394806#M114663</link>
    <description>&lt;P&gt;You're using &lt;CODE&gt;$1&lt;/CODE&gt; and &lt;CODE&gt;$2&lt;/CODE&gt; in your FORMAT values, while the first regex has only 1 capturing group and the second has none. So that doesn't line up, which is probably why these transforms are not getting applied.&lt;/P&gt;

&lt;P&gt;I think you need to adjust your regexes, such that you're capturing the parts before and after the string that needs to be anonymized and then specify a format like $1#####$2.&lt;/P&gt;</description>
    <pubDate>Mon, 18 Jun 2018 15:25:36 GMT</pubDate>
    <dc:creator>FrankVl</dc:creator>
    <dc:date>2018-06-18T15:25:36Z</dc:date>
    <item>
      <title>Cannot transform string with regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Cannot-transform-string-with-regex/m-p/394805#M114662</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;I am trying to transform a couple of strings that are being capture in my Splunk logs&lt;/P&gt;

&lt;P&gt;The string are similar to this&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;{"Key":"Authorization","Value":["Basic EAAAALhzFAxssvST1j4jBCAynyb3F9kHsHFWvijwNkuBb3pnY0zFtrz61YPlxQkP73l9p9ZusdBBfjSrDXgueEipT8xUuRk3tFPIAnmwFbGxluvRa3szorgtEq6VDXuIZL9RgA=="]},{"Key":"Authorization-Token","Value":["BCDC62F494410A7ABAE80457C9566F37"]}]&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I have tested the following regex expressions with a couple of tools, and they seem to match&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;"Authorization","Value":\["(Basic)\s[a-zA-Z0-9+\/]+={0,2}"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;"Authorization-Token","Value":\["[a-zA-Z0-9+]+"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I have the following in my &lt;STRONG&gt;$SPLUNK_HOME/etc/system/local/props.conf&lt;/STRONG&gt; file&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;[someapp]&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;TRANSFORMS-anonymize = authorization-anonymizer, authorization-token-anonymizer&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;And the following in &lt;STRONG&gt;my $SPLUNK_HOME/etc/system/local/transforms.conf&lt;/STRONG&gt; file&lt;/P&gt;

&lt;P&gt;`[authorization-anonymizer]&lt;BR /&gt;
REGEX = "Authorization","Value":["(Basic)\s[a-zA-Z0-9+\/]+={0,2}"&lt;BR /&gt;
FORMAT = $1"Value":["Basic ##############################################################################################################################$2 DEST_KEY = _raw&lt;/P&gt;

&lt;P&gt;[authorization-token-anonymizer]&lt;BR /&gt;
REGEX= "Authorization-Token","Value":["[a-zA-Z0-9+]+"&lt;BR /&gt;
FORMAT = $1"Value":["############################$2&lt;BR /&gt;
DEST_KEY = _raw`&lt;/P&gt;

&lt;P&gt;The intention is to replace the strings with # characters, but I clearly have misunderstood something, as the strings are not changing&lt;/P&gt;

&lt;P&gt;Could anyone help at all ?&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;

&lt;P&gt;_scott&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jun 2018 14:34:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Cannot-transform-string-with-regex/m-p/394805#M114662</guid>
      <dc:creator>scottkurtosys</dc:creator>
      <dc:date>2018-06-18T14:34:53Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot transform string with regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Cannot-transform-string-with-regex/m-p/394806#M114663</link>
      <description>&lt;P&gt;You're using &lt;CODE&gt;$1&lt;/CODE&gt; and &lt;CODE&gt;$2&lt;/CODE&gt; in your FORMAT values, while the first regex has only 1 capturing group and the second has none. So that doesn't line up, which is probably why these transforms are not getting applied.&lt;/P&gt;

&lt;P&gt;I think you need to adjust your regexes, such that you're capturing the parts before and after the string that needs to be anonymized and then specify a format like $1#####$2.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jun 2018 15:25:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Cannot-transform-string-with-regex/m-p/394806#M114663</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2018-06-18T15:25:36Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot transform string with regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Cannot-transform-string-with-regex/m-p/394807#M114664</link>
      <description>&lt;P&gt;Give this a try (transforms.conf)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[authorization-anonymizer] 
REGEX =(?m)^(.*"Authorization","Value":\["Basic\s*)[^\"]+(.+)
FORMAT = $1####################$2 
DEST_KEY = _raw 

[authorization-token-anonymizer] 
REGEX =(?m)^(.*"Authorization-Token","Value":\[")[^\"]+(.+)
FORMAT = $1####################$2 
DEST_KEY = _raw
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Jun 2018 15:33:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Cannot-transform-string-with-regex/m-p/394807#M114664</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-06-18T15:33:22Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot transform string with regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Cannot-transform-string-with-regex/m-p/394808#M114665</link>
      <description>&lt;P&gt;So if I were attempt to use something like this&lt;/P&gt;

&lt;P&gt;(.&lt;EM&gt;"Authorization","Value":["Basic\s)(.&lt;/EM&gt;={1,2})("]},{"Key":"Authorization-Token","Value":[")(.{32})(.*)&lt;/P&gt;

&lt;P&gt;Where each () capture group matches sections of the whole&lt;/P&gt;

&lt;P&gt;Could I then use a FORMAT of $1 ##### $3 ##### $5&lt;/P&gt;

&lt;P&gt;To hash out the two strings all in a single transform ?&lt;/P&gt;

&lt;P&gt;Or am I still misunderstanding the capture groups and FORMAT statement ?&lt;/P&gt;

&lt;P&gt;Also, do quote marks need to be escaped in Splunk regexes ?&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 11:50:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Cannot-transform-string-with-regex/m-p/394808#M114665</guid>
      <dc:creator>scottkurtosys</dc:creator>
      <dc:date>2018-06-27T11:50:08Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot transform string with regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Cannot-transform-string-with-regex/m-p/394809#M114666</link>
      <description>&lt;P&gt;Yes, something like that should work. Although there is not much purpose for putting the parts you don't want to keep in a capture group.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 11:55:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Cannot-transform-string-with-regex/m-p/394809#M114666</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2018-06-27T11:55:00Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot transform string with regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Cannot-transform-string-with-regex/m-p/394810#M114667</link>
      <description>&lt;P&gt;Thanks for pointing me in the right direction. Have got it working now&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":monkey_face:"&gt;🐵&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 15:19:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Cannot-transform-string-with-regex/m-p/394810#M114667</guid>
      <dc:creator>scottkurtosys</dc:creator>
      <dc:date>2018-06-27T15:19:37Z</dc:date>
    </item>
  </channel>
</rss>

