<?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 does Field extraction requires trim? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-does-Field-extraction-requires-trim/m-p/339509#M100684</link>
    <description>&lt;P&gt;Hey have you tried this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=iis|rex "^[^%]*%\d\w(?P&amp;lt;user_name&amp;gt;\w+)"|search user_name="jqpublic"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 30 Jan 2018 16:58:31 GMT</pubDate>
    <dc:creator>493669</dc:creator>
    <dc:date>2018-01-30T16:58:31Z</dc:date>
    <item>
      <title>Why does Field extraction requires trim?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-Field-extraction-requires-trim/m-p/339508#M100683</link>
      <description>&lt;P&gt;My iis data has a field name &lt;CODE&gt;cs_uri_query&lt;/CODE&gt;, for example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Cmd=Sync&amp;amp;User=XYZ%5Cjqpublic%40xyz.com&amp;amp;DeviceId=SEC539D6F312D5B3&amp;amp;DeviceType=SMG930V
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thusernameme is embedded in this field and I use the following regex to extract a new field called user_name:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;^[^%]*%\d\w(?P\w+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The new field is extracted properly and shows as:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;user_name  = jqpublic
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, if I do a specific search like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=iis host=server1 user_name=jqpublic
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I get no results.&lt;/P&gt;

&lt;P&gt;Only if I trim the field, or use a wildcard, are results returned:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=iis | eval user_name=trim(user_name) | search user_name=jqpublic
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any thoughts why trim is required here?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 16:45:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-Field-extraction-requires-trim/m-p/339508#M100683</guid>
      <dc:creator>JarrettM</dc:creator>
      <dc:date>2018-01-30T16:45:01Z</dc:date>
    </item>
    <item>
      <title>Re: Why does Field extraction requires trim?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-Field-extraction-requires-trim/m-p/339509#M100684</link>
      <description>&lt;P&gt;Hey have you tried this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=iis|rex "^[^%]*%\d\w(?P&amp;lt;user_name&amp;gt;\w+)"|search user_name="jqpublic"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Jan 2018 16:58:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-Field-extraction-requires-trim/m-p/339509#M100684</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-01-30T16:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: Why does Field extraction requires trim?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-Field-extraction-requires-trim/m-p/339510#M100685</link>
      <description>&lt;P&gt;Yes that works, as does creating a calculated field that trims the extracted field. But what I want to know is why any of this is necessary. Why doesn't the original extraction work correctly? &lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 17:11:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-Field-extraction-requires-trim/m-p/339510#M100685</guid>
      <dc:creator>JarrettM</dc:creator>
      <dc:date>2018-01-30T17:11:46Z</dc:date>
    </item>
    <item>
      <title>Re: Why does Field extraction requires trim?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-Field-extraction-requires-trim/m-p/339511#M100686</link>
      <description>&lt;P&gt;not sure which regex expression you are using...&lt;BR /&gt;
It seems your extracted &lt;CODE&gt;user_name&lt;/CODE&gt; field contains spaces so you need to trim...&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 17:17:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-Field-extraction-requires-trim/m-p/339511#M100686</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-01-30T17:17:29Z</dc:date>
    </item>
  </channel>
</rss>

