<?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: Modify field to remove extra characters in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Modify-field-to-remove-extra-characters/m-p/155511#M43760</link>
    <description>&lt;P&gt;You need the &lt;CODE&gt;replace&lt;/CODE&gt; command:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/replace"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/replace&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 12 Jun 2015 14:55:13 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2015-06-12T14:55:13Z</dc:date>
    <item>
      <title>Modify field to remove extra characters</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Modify-field-to-remove-extra-characters/m-p/155510#M43759</link>
      <description>&lt;P&gt;I have a search that returns a user field i.e. user="username". This gets reported by one system as user="u'username'" this is generating false positives for unknown users.&lt;/P&gt;

&lt;P&gt;I want to modify the user field, if necessary to remove the u' at the start and the ' at the end. I have a way but it seems cumbersome&lt;/P&gt;

&lt;P&gt;| eval user=if(like(user,"u'%'"), mvindex(split(user,"'") ,1) ,user)&lt;/P&gt;

&lt;P&gt;I'd be interested if there's a better way since I have another mis-report where the username has a : appended to it. using a similar eval but with an rtrim I could remove it but the search would be getting very heavy then.&lt;/P&gt;

&lt;P&gt;| eval user=if(like(user,"u'%'"), mvindex(split(user,"'") ,1) ,user)  | eval user=if(like(user,"%:"), rtrim(user,":") ,user)&lt;/P&gt;

&lt;P&gt;I feel there ought to be a regular expression way of doing this but I can't work it out.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2015 14:51:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Modify-field-to-remove-extra-characters/m-p/155510#M43759</guid>
      <dc:creator>terryjohn</dc:creator>
      <dc:date>2015-06-12T14:51:46Z</dc:date>
    </item>
    <item>
      <title>Re: Modify field to remove extra characters</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Modify-field-to-remove-extra-characters/m-p/155511#M43760</link>
      <description>&lt;P&gt;You need the &lt;CODE&gt;replace&lt;/CODE&gt; command:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/replace"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/replace&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2015 14:55:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Modify-field-to-remove-extra-characters/m-p/155511#M43760</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-06-12T14:55:13Z</dc:date>
    </item>
    <item>
      <title>Re: Modify field to remove extra characters</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Modify-field-to-remove-extra-characters/m-p/155512#M43761</link>
      <description>&lt;P&gt;Check out the &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.3/SearchReference/replace"&gt;replace&lt;/A&gt; command&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2015 14:56:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Modify-field-to-remove-extra-characters/m-p/155512#M43761</guid>
      <dc:creator>masonmorales</dc:creator>
      <dc:date>2015-06-12T14:56:15Z</dc:date>
    </item>
    <item>
      <title>Re: Modify field to remove extra characters</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Modify-field-to-remove-extra-characters/m-p/155513#M43762</link>
      <description>&lt;P&gt;Thanks both it took me a while to work it out that it was eval replace command not the other replace but with the right regex it seems to work&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval user=replace(user,"(^u')?(.+)[':]$","\2")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Jun 2015 16:43:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Modify-field-to-remove-extra-characters/m-p/155513#M43762</guid>
      <dc:creator>terryjohn</dc:creator>
      <dc:date>2015-06-12T16:43:37Z</dc:date>
    </item>
    <item>
      <title>Re: Modify field to remove extra characters</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Modify-field-to-remove-extra-characters/m-p/155514#M43763</link>
      <description>&lt;P&gt;Here's a solution using the aforementioned &lt;CODE&gt;replace&lt;/CODE&gt; command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval user="u'username" | replace u'* with *
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(Everything prior to "| replace" is used to make a single sample event on which to test the replace. Omit it in your actual search.)&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2016 14:02:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Modify-field-to-remove-extra-characters/m-p/155514#M43763</guid>
      <dc:creator>hrottenberg_spl</dc:creator>
      <dc:date>2016-06-29T14:02:16Z</dc:date>
    </item>
  </channel>
</rss>

