<?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: Why is there a space added to my field extracted with rex? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-is-there-a-space-added-to-my-field-extracted-with-rex/m-p/235139#M69838</link>
    <description>&lt;P&gt;I tried trim, doen´t make a difference.&lt;/P&gt;

&lt;P&gt;Thank for the answers.&lt;/P&gt;</description>
    <pubDate>Thu, 24 Nov 2016 10:27:15 GMT</pubDate>
    <dc:creator>dkeck</dc:creator>
    <dc:date>2016-11-24T10:27:15Z</dc:date>
    <item>
      <title>Why is there a space added to my field extracted with rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-there-a-space-added-to-my-field-extracted-with-rex/m-p/235135#M69834</link>
      <description>&lt;P&gt;Hi &lt;/P&gt;

&lt;P&gt;I have the following rex to test a new field extraction:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|rex "(?s)&amp;lt;Sql_Text&amp;gt;(((?&amp;lt;a_action&amp;gt;.*)))&amp;lt;/Sql_Text&amp;gt;" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will give me SQLText without the comments. It's working fine. &lt;/P&gt;

&lt;P&gt;The Problem is, when I compared the new(a_action) and the old field(action) this : &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | eval diff=if(a_action=action,0,1) | eval nospace=substr(a_action , 57,58)| where diff=1 | table action a_action nospace | eval x=length(action) | eval y=length(a_action) | eval z=length(nospace) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;tells me, that the a_action is 1 character longer than action field. I figured that there is a space on the end of the string of the a_action field. I can't tell why, is there something wrong in my regex?&lt;/P&gt;

&lt;P&gt;Kind regards&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:51:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-there-a-space-added-to-my-field-extracted-with-rex/m-p/235135#M69834</guid>
      <dc:creator>dkeck</dc:creator>
      <dc:date>2020-09-29T11:51:33Z</dc:date>
    </item>
    <item>
      <title>Re: Why is there a space added to my field extracted with rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-there-a-space-added-to-my-field-extracted-with-rex/m-p/235136#M69835</link>
      <description>&lt;P&gt;could you share an example of your log?&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2016 12:47:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-there-a-space-added-to-my-field-extracted-with-rex/m-p/235136#M69835</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2016-11-22T12:47:32Z</dc:date>
    </item>
    <item>
      <title>Re: Why is there a space added to my field extracted with rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-there-a-space-added-to-my-field-extracted-with-rex/m-p/235137#M69836</link>
      <description>&lt;P&gt;Before executing rex command can you try the following:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;eval Sql_Text=trim(Sql_Text) |&lt;/STRONG&gt; &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:51:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-there-a-space-added-to-my-field-extracted-with-rex/m-p/235137#M69836</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-09-29T11:51:35Z</dc:date>
    </item>
    <item>
      <title>Re: Why is there a space added to my field extracted with rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-there-a-space-added-to-my-field-extracted-with-rex/m-p/235138#M69837</link>
      <description>&lt;P&gt;I can´t share the logs sry.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2016 10:22:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-there-a-space-added-to-my-field-extracted-with-rex/m-p/235138#M69837</guid>
      <dc:creator>dkeck</dc:creator>
      <dc:date>2016-11-24T10:22:32Z</dc:date>
    </item>
    <item>
      <title>Re: Why is there a space added to my field extracted with rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-there-a-space-added-to-my-field-extracted-with-rex/m-p/235139#M69838</link>
      <description>&lt;P&gt;I tried trim, doen´t make a difference.&lt;/P&gt;

&lt;P&gt;Thank for the answers.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2016 10:27:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-there-a-space-added-to-my-field-extracted-with-rex/m-p/235139#M69838</guid>
      <dc:creator>dkeck</dc:creator>
      <dc:date>2016-11-24T10:27:15Z</dc:date>
    </item>
    <item>
      <title>Re: Why is there a space added to my field extracted with rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-there-a-space-added-to-my-field-extracted-with-rex/m-p/235140#M69839</link>
      <description>&lt;P&gt;Have you tried to run rex command with and without &lt;STRONG&gt;(?s)&lt;/STRONG&gt;?&lt;/P&gt;

&lt;P&gt;If possible check directly in SQL Server DB whether the extracted value SQL_Text in the table/column has new line CHAR(13) and/or linefeed CHAR(10) characters or not.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2016 11:02:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-there-a-space-added-to-my-field-extracted-with-rex/m-p/235140#M69839</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2016-11-24T11:02:14Z</dc:date>
    </item>
    <item>
      <title>Re: Why is there a space added to my field extracted with rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-there-a-space-added-to-my-field-extracted-with-rex/m-p/235141#M69840</link>
      <description>&lt;P&gt;No difference without (?s).&lt;/P&gt;

&lt;P&gt;Why should the source of this be the SQL Server itself? the old field "action" doens´t have a space, its added during the extration. &lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2016 11:47:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-there-a-space-added-to-my-field-extracted-with-rex/m-p/235141#M69840</guid>
      <dc:creator>dkeck</dc:creator>
      <dc:date>2016-11-24T11:47:23Z</dc:date>
    </item>
    <item>
      <title>Re: Why is there a space added to my field extracted with rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-there-a-space-added-to-my-field-extracted-with-rex/m-p/235142#M69841</link>
      <description>&lt;P&gt;So here is a sample of the Table I created with the query :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;field names: action  : a_action :nospace : x : y : z
vlaues: begin dbms_application_info.set_module(:1 , :2 ); end;  begin dbms_application_info.set_module(:1 , :2 ); end;  d;  56  57  3  
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;There you can see that "z" only has 2 charakters in it plus the "invisible" space&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2016 11:53:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-there-a-space-added-to-my-field-extracted-with-rex/m-p/235142#M69841</guid>
      <dc:creator>dkeck</dc:creator>
      <dc:date>2016-11-24T11:53:21Z</dc:date>
    </item>
    <item>
      <title>Re: Why is there a space added to my field extracted with rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-there-a-space-added-to-my-field-extracted-with-rex/m-p/235143#M69842</link>
      <description>&lt;P&gt;Since you have not provided sample log or log example, I was just guessing based on SQL_txt field that the data is coming from SQL Server. Nevertheless, the reason why I asked to check (?s) was because:&lt;BR /&gt;
1) You have already verified that there is no space in original field, by testing trim.&lt;BR /&gt;
2) Sometimes non special characters like Line Feed(\r) and New Lines(\n) are displayed as space. The (?s) specified tells rex command to extract from only single line and you have used .* as the extractor. Which fetches until newline character is found unless mode is single line or (?s).&lt;/P&gt;

&lt;P&gt;Now that you have mentioned that even this does not help, may imply that you do not have new line character in the end of data. Just try .+ instead of .* once and see.&lt;/P&gt;

&lt;P&gt;If this does not help you will have to give some mock data or anonymized data if it is confidential, or reach out to Splunk support directly.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2016 11:55:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-there-a-space-added-to-my-field-extracted-with-rex/m-p/235143#M69842</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2016-11-24T11:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: Why is there a space added to my field extracted with rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-there-a-space-added-to-my-field-extracted-with-rex/m-p/235144#M69843</link>
      <description>&lt;P&gt;Can you perform the following on action field as well? &lt;/P&gt;

&lt;P&gt;eval finalCharacter=substr(action , 57,58)&lt;/P&gt;

&lt;P&gt;Also see if rex can be changed to the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"\&amp;lt;Sql_Text\&amp;gt;(?&amp;lt;a_action&amp;gt;.*)\&amp;lt;\/Sql_Text\&amp;gt;"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Nov 2016 12:21:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-there-a-space-added-to-my-field-extracted-with-rex/m-p/235144#M69843</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2016-11-24T12:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: Why is there a space added to my field extracted with rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-there-a-space-added-to-my-field-extracted-with-rex/m-p/235145#M69844</link>
      <description>&lt;P&gt;Ok it appeared that the space came from something totally different than the field extraction.&lt;/P&gt;

&lt;P&gt;Thanks for the time.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Dec 2016 06:55:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-there-a-space-added-to-my-field-extracted-with-rex/m-p/235145#M69844</guid>
      <dc:creator>dkeck</dc:creator>
      <dc:date>2016-12-02T06:55:06Z</dc:date>
    </item>
  </channel>
</rss>

