<?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: Help with trimming characters in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Help-with-trimming-characters/m-p/248788#M74306</link>
    <description>&lt;P&gt;Yes, that can work also. I will keep this for further use - I'm sure that I will be running across things like this and can use all ways possible.&lt;/P&gt;</description>
    <pubDate>Wed, 27 Jan 2016 11:37:04 GMT</pubDate>
    <dc:creator>TheJagoff</dc:creator>
    <dc:date>2016-01-27T11:37:04Z</dc:date>
    <item>
      <title>Help with trimming characters</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-trimming-characters/m-p/248781#M74299</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;Having some issues here. I have the following values in a field named &lt;STRONG&gt;populace&lt;/STRONG&gt;&lt;BR /&gt;
The values are encased in a  &amp;lt; and &amp;gt; (I tried to show it in the thread but it won't)&lt;/P&gt;

&lt;P&gt;I need it to look like this:&lt;BR /&gt;
15&lt;BR /&gt;
12&lt;BR /&gt;
4&lt;BR /&gt;
0&lt;BR /&gt;
...&lt;/P&gt;

&lt;P&gt;I need to just get the numeric values out of this field and have used ltrim and rtrim, but still see the unwanted characters of &amp;lt; and &amp;gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval field=rtrim(populace,"&amp;gt;") | eval field=ltrim(populace,"&amp;lt;")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I also tried this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval populace=trim("&amp;lt;")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then finally I tried:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=populace "&amp;lt;:(?.* &amp;gt;:)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any guidance/help would be greatly appreciated.&lt;/P&gt;

&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2016 23:40:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-trimming-characters/m-p/248781#M74299</guid>
      <dc:creator>TheJagoff</dc:creator>
      <dc:date>2016-01-26T23:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: Help with trimming characters</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-trimming-characters/m-p/248782#M74300</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Sorry if I missed anything but your post is a bit confusing without the escaping characters. In future make sure you enclose all your queries and examples between code tags (the icon with 1s and 0s above)&lt;/P&gt;

&lt;P&gt;Anyway, if you just want to capture numerical values you can use this instead:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearch
| rex field=populace max_match=0 "(?&amp;lt;justNumbers&amp;gt;\d+)"
| table justNumbers
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let me know if that works for you. Otherwise please provide more info about your data. &lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
J&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2016 23:57:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-trimming-characters/m-p/248782#M74300</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-01-26T23:57:26Z</dc:date>
    </item>
    <item>
      <title>Re: Help with trimming characters</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-trimming-characters/m-p/248783#M74301</link>
      <description>&lt;P&gt;The easiest thing to do is to rex the field, matching on the less-than-sign, then doing a named capture group for anything not matching a more-than-sign, using a different field name. Here is an example where I created the fields you said, and then extracted what is in them:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 | eval populace="
 populace=&amp;lt;15&amp;gt;
 populace=&amp;lt;12&amp;gt;
 populace=&amp;lt;4&amp;gt;
 populace=&amp;lt;0&amp;gt;"
| rex max_match=0 field=populace "\x3C(?&amp;lt;populacext&amp;gt;[^\x3E]+)" | table populacext populace
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The only thing you are interested in here is the rex -- the rest is just window-dressing to create the basis for it in search. In your case you would not need the max_match=0&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jan 2016 00:06:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-trimming-characters/m-p/248783#M74301</guid>
      <dc:creator>wrangler2x</dc:creator>
      <dc:date>2016-01-27T00:06:09Z</dc:date>
    </item>
    <item>
      <title>Re: Help with trimming characters</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-trimming-characters/m-p/248784#M74302</link>
      <description>&lt;P&gt;Oh, and I don't know why splunk anwers place a &lt;STRONG&gt;5.&lt;/STRONG&gt; in front of the line &lt;STRONG&gt;populace=&amp;lt;0&amp;gt;"&lt;/STRONG&gt; -- don't include that in your search when you try my test.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jan 2016 00:07:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-trimming-characters/m-p/248784#M74302</guid>
      <dc:creator>wrangler2x</dc:creator>
      <dc:date>2016-01-27T00:07:24Z</dc:date>
    </item>
    <item>
      <title>Re: Help with trimming characters</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-trimming-characters/m-p/248785#M74303</link>
      <description>&lt;P&gt;There are multiple options, rex with sed OR replace to do that&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 | eval text=" &amp;lt;15&amp;gt;"
  | table text  | eval text1=text | rex mode=sed field=text1 "s/(\&amp;lt;|\&amp;gt;)//g" | eval text3=replace(replace(text,"&amp;lt;",""),"&amp;gt;","")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Jan 2016 03:31:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-trimming-characters/m-p/248785#M74303</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-01-27T03:31:54Z</dc:date>
    </item>
    <item>
      <title>Re: Help with trimming characters</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-trimming-characters/m-p/248786#M74304</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;The following gives me the output you are looking for:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 
| eval populace="
    populace=&amp;lt;15&amp;gt;
    populace=&amp;lt;12&amp;gt;
    populace=&amp;lt;4&amp;gt;
    populace=&amp;lt;0&amp;gt;"
 | rex field=populace max_match=0 "(?&amp;lt;justNumbers&amp;gt;\d+)"
 | table justNumbers
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OUTPUT: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;justNumbers
15
12
4
0 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you take the bottom two lines and append that to your search if should give you what you are looking for. Otherwise please provide more information.&lt;/P&gt;

&lt;P&gt;The following works too:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 
| eval populace="
    &amp;lt;15&amp;gt;
    &amp;lt;12&amp;gt;
    &amp;lt;4&amp;gt;
    &amp;lt;0&amp;gt;"
 | rex field=populace max_match=0 "(?&amp;lt;justNumbers&amp;gt;\d+)"
 | table justNumbers
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 
| eval populace="
    &amp;lt;15
    12
    4
    0&amp;gt;"
 | rex field=populace max_match=0 "(?&amp;lt;justNumbers&amp;gt;\d+)"
 | table justNumbers
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Jan 2016 09:34:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-trimming-characters/m-p/248786#M74304</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-01-27T09:34:50Z</dc:date>
    </item>
    <item>
      <title>Re: Help with trimming characters</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-trimming-characters/m-p/248787#M74305</link>
      <description>&lt;P&gt;Hey that works perfectly. Many thanks!&lt;/P&gt;

&lt;P&gt;I apologize for not being able to show the issue better but I did encase the numbers in the &amp;lt;&amp;gt; but at first, the numbers were not showing, then I put a \ in front of the &amp;gt; and I was told that I had an xml phrase and couldn't post that. I also should have stated that there are thousands of lines where this is happening. Again, I thank you for your  insight.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jan 2016 11:35:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-trimming-characters/m-p/248787#M74305</guid>
      <dc:creator>TheJagoff</dc:creator>
      <dc:date>2016-01-27T11:35:43Z</dc:date>
    </item>
    <item>
      <title>Re: Help with trimming characters</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-trimming-characters/m-p/248788#M74306</link>
      <description>&lt;P&gt;Yes, that can work also. I will keep this for further use - I'm sure that I will be running across things like this and can use all ways possible.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jan 2016 11:37:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-trimming-characters/m-p/248788#M74306</guid>
      <dc:creator>TheJagoff</dc:creator>
      <dc:date>2016-01-27T11:37:04Z</dc:date>
    </item>
  </channel>
</rss>

