<?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: How to use rex and ltrim to extract this field in my data? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-and-ltrim-to-extract-this-field-in-my-data/m-p/302522#M91047</link>
    <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;.... | rex field=EMP mode=sed "s/^0000//"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 19 Feb 2017 01:43:28 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2017-02-19T01:43:28Z</dc:date>
    <item>
      <title>How to use rex and ltrim to extract this field in my data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-and-ltrim-to-extract-this-field-in-my-data/m-p/302519#M91044</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have a field EMP, I need to remove the 0000 present before the field, is this do able?&lt;BR /&gt;
like, I'm using Rex and ltrim &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|rex field=EMP "(?\d{5})$"|eval EMP=if (like (EMP,"0000%"),ltrim(EMP,"0000\\"),EMP)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;EMP:&lt;BR /&gt;
000012345&lt;BR /&gt;
000000002(its removing all 0's but i need 00001)&lt;BR /&gt;
0000ABCDEFGH&lt;/P&gt;

&lt;P&gt;Expected output;&lt;BR /&gt;
12345&lt;BR /&gt;
00002&lt;BR /&gt;
ABCDEFGH&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 22:00:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-and-ltrim-to-extract-this-field-in-my-data/m-p/302519#M91044</guid>
      <dc:creator>kiran331</dc:creator>
      <dc:date>2017-02-16T22:00:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to use rex and ltrim to extract this field in my data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-and-ltrim-to-extract-this-field-in-my-data/m-p/302520#M91045</link>
      <description>&lt;P&gt;try something like this,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|stats c |eval f="000012345,000000002,0000ABCDEFGH,100000" |eval field=split(f,",") | fields - f | mvexpand field |rex mode=sed field=field  "s/^(0000)(.*)/\2/g"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Feb 2017 22:35:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-and-ltrim-to-extract-this-field-in-my-data/m-p/302520#M91045</guid>
      <dc:creator>mpreddy</dc:creator>
      <dc:date>2017-02-16T22:35:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to use rex and ltrim to extract this field in my data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-and-ltrim-to-extract-this-field-in-my-data/m-p/302521#M91046</link>
      <description>&lt;P&gt;This makes test data -&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval EMP="000012345 0000ABC 000000002 george" | makemv EMP| mvexpand EMP 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;this answers the question &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval EMP2=if (like (EMP,"0000%"),substr(EMP,5,len(EMP)-4),EMP)
| table EMP EMP2 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;With this result &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;EMP         EMP2
000012345   12345
0000ABC     ABC
000000002   00002
george      george
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Feb 2017 22:46:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-and-ltrim-to-extract-this-field-in-my-data/m-p/302521#M91046</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-02-16T22:46:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to use rex and ltrim to extract this field in my data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-and-ltrim-to-extract-this-field-in-my-data/m-p/302522#M91047</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;.... | rex field=EMP mode=sed "s/^0000//"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 19 Feb 2017 01:43:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-and-ltrim-to-extract-this-field-in-my-data/m-p/302522#M91047</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-02-19T01:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to use rex and ltrim to extract this field in my data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-and-ltrim-to-extract-this-field-in-my-data/m-p/302523#M91048</link>
      <description>&lt;P&gt;@kiran331 - Did one of the answers below help provide a solution your question? If yes, please click “Accept” below the best answer to resolve this post and upvote anything that was helpful. If no, please leave a comment with more feedback. Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2017 02:46:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-and-ltrim-to-extract-this-field-in-my-data/m-p/302523#M91048</guid>
      <dc:creator>aaraneta_splunk</dc:creator>
      <dc:date>2017-03-20T02:46:17Z</dc:date>
    </item>
  </channel>
</rss>

