<?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: Regular expression used in transform not performing as expected in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regular-expression-used-in-transform-not-performing-as-expected/m-p/103490#M26755</link>
    <description>&lt;P&gt;Yeah, I'm aware of this though Perl and PCRE are not strictly identical.  Regardless the regex can be changed to be &lt;/P&gt;

&lt;P&gt;(?:^|(?&amp;lt;=%2C))(.+?)(?=%2C|$) &lt;/P&gt;

&lt;P&gt;which will also work in Perl but still result in the same behavior from Splunk.&lt;/P&gt;</description>
    <pubDate>Tue, 29 Jan 2013 18:15:40 GMT</pubDate>
    <dc:creator>jklumpp_splunk</dc:creator>
    <dc:date>2013-01-29T18:15:40Z</dc:date>
    <item>
      <title>Regular expression used in transform not performing as expected</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-expression-used-in-transform-not-performing-as-expected/m-p/103488#M26753</link>
      <description>&lt;P&gt;I have written a Regex to perform an extraction in transforms.conf that I've tested in multiple PCRE compliant regular expression editors and it works perfectly, but the results in Splunk after it is run through a transform are different.  Here are the details....&lt;/P&gt;

&lt;P&gt;I have a field named &lt;STRONG&gt;RECORD_NAMES&lt;/STRONG&gt; with a value of...&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;Zx1%2CEOS 5D Mark II%252C body%2CHR10 &amp;amp; Tenba Xpress: Medium Pouch%252C Black/Teal%2CDigital IXUS 85 IS%2CZ980%2CFUN Flash Single Use Camera%252C 1+1 Pack%2CPrima Super 130U Date%2CEOS 5D Mark II + EF 24-105mm f4L IS USM%2CQuickCam® Chat for Skype%2CDigital IXUS 80 IS%2C15x50 IS%2CCyber-shot T70%252C Black&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;From this I need to create a new multi-value field by breaking down each individual value delimited by &lt;STRONG&gt;%2C&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Here is my regex...&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;(?&amp;lt;=%2C|^)(.+?)(?=%2C|$)&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;This regex extracts each value as expected when run in a regex editor but after the transform each of the extracted values (with exception of the first &lt;STRONG&gt;Zx1&lt;/STRONG&gt;) is prefixed by &lt;STRONG&gt;%2C&lt;/STRONG&gt; which as specified above is the delimiter and should not be there.&lt;/P&gt;

&lt;P&gt;Here is how my transform to create a new field &lt;STRONG&gt;aaa&lt;/STRONG&gt; is configured...&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;[logserver_output-Record_Name]&lt;BR /&gt;&lt;BR /&gt;
SOURCE_KEY = RECORD_NAMES&lt;BR /&gt;&lt;BR /&gt;
REGEX = (?&amp;lt;=%2C|^)(.+?)(?=%2C|$)&lt;BR /&gt;&lt;BR /&gt;
FORMAT = aaa::$1&lt;BR /&gt;&lt;BR /&gt;
MV_ADD = True&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;Here are the actual individual values of my new field &lt;STRONG&gt;aaa&lt;/STRONG&gt; in Splunk after that transform...&lt;/P&gt;

&lt;P&gt;Zx1&lt;BR /&gt;&lt;BR /&gt;
%2CZ980&lt;BR /&gt;&lt;BR /&gt;
%2CQuickCam® Chat for Skype&lt;BR /&gt;&lt;BR /&gt;
%2CPrima Super 130U Date&lt;BR /&gt;&lt;BR /&gt;
%2CHR10 &amp;amp; Tenba Xpress: Medium Pouch%252C Black/Teal&lt;BR /&gt;&lt;BR /&gt;
%2CFUN Flash Single Use Camera%252C 1+1 Pack&lt;BR /&gt;&lt;BR /&gt;
%2CEOS 5D Mark II%252C body&lt;BR /&gt;&lt;BR /&gt;
%2CEOS 5D Mark II + EF 24-105mm f4L IS USM&lt;BR /&gt;&lt;BR /&gt;
%2CDigital IXUS 85 IS&lt;BR /&gt;&lt;BR /&gt;
%2CDigital IXUS 80 IS&lt;BR /&gt;
%2CCyber-shot T70%252C Black&lt;BR /&gt;
%2C15x50 IS &lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:12:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-expression-used-in-transform-not-performing-as-expected/m-p/103488#M26753</guid>
      <dc:creator>jklumpp_splunk</dc:creator>
      <dc:date>2020-09-28T13:12:11Z</dc:date>
    </item>
    <item>
      <title>Re: Regular expression used in transform not performing as expected</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-expression-used-in-transform-not-performing-as-expected/m-p/103489#M26754</link>
      <description>&lt;P&gt;I'm surprised that that works in a other pcre engines.&lt;/P&gt;

&lt;P&gt;When I run that regex in perl I get this : &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;Variable length lookbehind not implemented in regex&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;This might be more suited :&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;(?:%2C|^)(.+?)(?=%2C|$)&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jan 2013 18:11:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-expression-used-in-transform-not-performing-as-expected/m-p/103489#M26754</guid>
      <dc:creator>jonuwz</dc:creator>
      <dc:date>2013-01-29T18:11:31Z</dc:date>
    </item>
    <item>
      <title>Re: Regular expression used in transform not performing as expected</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-expression-used-in-transform-not-performing-as-expected/m-p/103490#M26755</link>
      <description>&lt;P&gt;Yeah, I'm aware of this though Perl and PCRE are not strictly identical.  Regardless the regex can be changed to be &lt;/P&gt;

&lt;P&gt;(?:^|(?&amp;lt;=%2C))(.+?)(?=%2C|$) &lt;/P&gt;

&lt;P&gt;which will also work in Perl but still result in the same behavior from Splunk.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jan 2013 18:15:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-expression-used-in-transform-not-performing-as-expected/m-p/103490#M26755</guid>
      <dc:creator>jklumpp_splunk</dc:creator>
      <dc:date>2013-01-29T18:15:40Z</dc:date>
    </item>
    <item>
      <title>Re: Regular expression used in transform not performing as expected</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-expression-used-in-transform-not-performing-as-expected/m-p/103491#M26756</link>
      <description>&lt;P&gt;You're looking for %2C OR the start of a line. Are you entirely sure that the regex will prefer to match %2C(data) instead of ^(%2Cdata)?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jan 2013 20:34:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-expression-used-in-transform-not-performing-as-expected/m-p/103491#M26756</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2013-01-29T20:34:38Z</dc:date>
    </item>
    <item>
      <title>Re: Regular expression used in transform not performing as expected</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-expression-used-in-transform-not-performing-as-expected/m-p/103492#M26757</link>
      <description>&lt;P&gt;The issue seems to be related to the start of line &lt;STRONG&gt;^&lt;/STRONG&gt; thanks Ayn, because I removed that and it will match all values except the first without including &lt;EM&gt;%2C&lt;/EM&gt;.  No matter how I tried to reconfigure the regex though I could not find a way to resolve the issue, so instead I am performing two transforms to get around the issue.  The first extracts the first value and the second extracts all remaining values.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jan 2013 15:59:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-expression-used-in-transform-not-performing-as-expected/m-p/103492#M26757</guid>
      <dc:creator>jklumpp_splunk</dc:creator>
      <dc:date>2013-01-30T15:59:58Z</dc:date>
    </item>
    <item>
      <title>Re: Regular expression used in transform not performing as expected</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-expression-used-in-transform-not-performing-as-expected/m-p/103493#M26758</link>
      <description>&lt;P&gt;Thanks Ayn, the ^ does seem to be the cause of the issue though I was unable to resolve it directly it did help me find a workaround (see comment on my original question).&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jan 2013 16:01:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-expression-used-in-transform-not-performing-as-expected/m-p/103493#M26758</guid>
      <dc:creator>jklumpp_splunk</dc:creator>
      <dc:date>2013-01-30T16:01:25Z</dc:date>
    </item>
  </channel>
</rss>

