<?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: The &amp;quot;ltrim&amp;quot; problem in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/The-quot-ltrim-quot-problem/m-p/603964#M210108</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;, many thanks for providing a quick solution. Apologies for my late reply.&lt;BR /&gt;&lt;BR /&gt;What I used to solve the problem was slightly different but definitely lengthy (in terms of functions, commands used). See below example for my solution:&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;| makeresults&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval username="dev_vishal"&lt;/SPAN&gt;&lt;BR /&gt;| eval devFlag=if(match(username,".*dev_*."),1,0), tempName=split(username,"_")&lt;BR /&gt;| eval newUsername = if(devFlag=1,mvindex(tempName,1),username)&lt;BR /&gt;| table username newUsername&lt;/P&gt;&lt;P&gt;Output:&lt;BR /&gt;username = dev_vishal&lt;BR /&gt;newUsername = vishal&lt;BR /&gt;&lt;BR /&gt;Problem is, now I'm receiving some logs where usernames are a bit different such as, USER_sajal, temp_sajal etc. So to handle that, I would use your suggestion above i.e the "rex" command. See below example:&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval username="dev_vishal"&lt;/SPAN&gt;&lt;BR /&gt;| rex field=username "\w+_(?&amp;lt;newUsername&amp;gt;.*)"&lt;BR /&gt;&lt;BR /&gt;In this way it would work for all kinds of usernames. Be it dev_vishal, USER_sajal or temp_sajal etc.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Sajal&lt;/P&gt;</description>
    <pubDate>Thu, 30 Jun 2022 12:46:24 GMT</pubDate>
    <dc:creator>sajalbansal2</dc:creator>
    <dc:date>2022-06-30T12:46:24Z</dc:date>
    <item>
      <title>The "ltrim" problem</title>
      <link>https://community.splunk.com/t5/Splunk-Search/The-quot-ltrim-quot-problem/m-p/602301#M209643</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;
&lt;P&gt;There's a small problem I'm having while using the ltrim function.&lt;BR /&gt;&lt;BR /&gt;Query:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| makeresults
| eval username="dev_vishal"
| eval trimName=ltrim(username,"dev_")
| table username trimName&lt;/LI-CODE&gt;
&lt;P&gt;Output:&lt;BR /&gt;username = dev_vishal&lt;BR /&gt;trimName = ishal&lt;BR /&gt;&lt;BR /&gt;What I really want is to trim the "dev_" out of "dev_vishal". I noticed that this works well with any other username which does not start with a "v". For example:&lt;BR /&gt;&lt;BR /&gt;Query:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| makeresults
| eval username="dev_sajal"
| eval trimName=ltrim(username,"dev_")
| table username trimName&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;Output:&lt;BR /&gt;username = dev_sajal&lt;BR /&gt;trimName = sajal&lt;BR /&gt;&lt;BR /&gt;Request the Splunk community to please help me with this.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Sajal&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jun 2022 13:26:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/The-quot-ltrim-quot-problem/m-p/602301#M209643</guid>
      <dc:creator>sajalbansal2</dc:creator>
      <dc:date>2022-06-30T13:26:23Z</dc:date>
    </item>
    <item>
      <title>Re: The "ltrim" problem</title>
      <link>https://community.splunk.com/t5/Splunk-Search/The-quot-ltrim-quot-problem/m-p/602307#M209648</link>
      <description>&lt;P&gt;ltrim() is removing any of those characters from the left - you would have the same issue with ltrim("e_vd",...) or with "dev_david". Try this instead&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex field=username "^dev_(?&amp;lt;trimName&amp;gt;.*)"&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 18 Jun 2022 06:19:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/The-quot-ltrim-quot-problem/m-p/602307#M209648</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-06-18T06:19:54Z</dc:date>
    </item>
    <item>
      <title>Re: The "ltrim" problem</title>
      <link>https://community.splunk.com/t5/Splunk-Search/The-quot-ltrim-quot-problem/m-p/603964#M210108</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;, many thanks for providing a quick solution. Apologies for my late reply.&lt;BR /&gt;&lt;BR /&gt;What I used to solve the problem was slightly different but definitely lengthy (in terms of functions, commands used). See below example for my solution:&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;| makeresults&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval username="dev_vishal"&lt;/SPAN&gt;&lt;BR /&gt;| eval devFlag=if(match(username,".*dev_*."),1,0), tempName=split(username,"_")&lt;BR /&gt;| eval newUsername = if(devFlag=1,mvindex(tempName,1),username)&lt;BR /&gt;| table username newUsername&lt;/P&gt;&lt;P&gt;Output:&lt;BR /&gt;username = dev_vishal&lt;BR /&gt;newUsername = vishal&lt;BR /&gt;&lt;BR /&gt;Problem is, now I'm receiving some logs where usernames are a bit different such as, USER_sajal, temp_sajal etc. So to handle that, I would use your suggestion above i.e the "rex" command. See below example:&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval username="dev_vishal"&lt;/SPAN&gt;&lt;BR /&gt;| rex field=username "\w+_(?&amp;lt;newUsername&amp;gt;.*)"&lt;BR /&gt;&lt;BR /&gt;In this way it would work for all kinds of usernames. Be it dev_vishal, USER_sajal or temp_sajal etc.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Sajal&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jun 2022 12:46:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/The-quot-ltrim-quot-problem/m-p/603964#M210108</guid>
      <dc:creator>sajalbansal2</dc:creator>
      <dc:date>2022-06-30T12:46:24Z</dc:date>
    </item>
  </channel>
</rss>

