<?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 tonumber() not working in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/tonumber-not-working/m-p/82682#M181941</link>
    <description>&lt;P&gt;I have an extracted field that is alphanumeric and splunk is interpreting it as a string, obviously. But I am using rtrim to remove the alpha characters and leave only numeric characters. But as I confirmed with if(isstr()) splunk is still interpreting the field as a string. So, I tried to convert to number with tonumber() but results are coming back null. Any suggestions?&lt;/P&gt;</description>
    <pubDate>Wed, 09 Jan 2013 19:14:19 GMT</pubDate>
    <dc:creator>jedatt01</dc:creator>
    <dc:date>2013-01-09T19:14:19Z</dc:date>
    <item>
      <title>tonumber() not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/tonumber-not-working/m-p/82682#M181941</link>
      <description>&lt;P&gt;I have an extracted field that is alphanumeric and splunk is interpreting it as a string, obviously. But I am using rtrim to remove the alpha characters and leave only numeric characters. But as I confirmed with if(isstr()) splunk is still interpreting the field as a string. So, I tried to convert to number with tonumber() but results are coming back null. Any suggestions?&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jan 2013 19:14:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/tonumber-not-working/m-p/82682#M181941</guid>
      <dc:creator>jedatt01</dc:creator>
      <dc:date>2013-01-09T19:14:19Z</dc:date>
    </item>
    <item>
      <title>Re: tonumber() not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/tonumber-not-working/m-p/82683#M181942</link>
      <description>&lt;P&gt;figured out a workaround from another post that converts my string to a number. Could there be a bug in tonumber()?&lt;/P&gt;

&lt;P&gt;eval TE=strptime(rtrim(Total_Energy,"kWH"),"%s")&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jan 2013 19:36:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/tonumber-not-working/m-p/82683#M181942</guid>
      <dc:creator>jedatt01</dc:creator>
      <dc:date>2013-01-09T19:36:43Z</dc:date>
    </item>
    <item>
      <title>Re: tonumber() not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/tonumber-not-working/m-p/82684#M181943</link>
      <description>&lt;P&gt;I don't suppose you could give an example of the field? That would help immensely. I'm guessing it's something like "100 kWH"?&lt;/P&gt;

&lt;P&gt;Have you confirmed that &lt;CODE&gt;eval xx=rtrim(Total_Energy,"kWH")&lt;/CODE&gt; results in something that looks like a number? Is there a space in your "kWH" that I can't see and is there a space between the number and the string? A trailing space might make the rtrim output look not like a number and would be hard to see.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;rtrim&lt;/CODE&gt; seems kinda like an odd choice, though it seems like it should work. Personally I would have used a regular expression with &lt;CODE&gt;replace&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;replace(Total_Energy, "^(\d+)", "\1")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Jan 2013 23:19:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/tonumber-not-working/m-p/82684#M181943</guid>
      <dc:creator>Wilcooley</dc:creator>
      <dc:date>2013-01-09T23:19:08Z</dc:date>
    </item>
    <item>
      <title>Re: tonumber() not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/tonumber-not-working/m-p/82685#M181944</link>
      <description>&lt;P&gt;That was the problem. I was forgetting about the space before the kWH. this worked correctly &lt;BR /&gt;
eval xx=rtrim(Total_Energy, " kWH")&lt;BR /&gt;
Thanks!!&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2013 01:01:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/tonumber-not-working/m-p/82685#M181944</guid>
      <dc:creator>jedatt01</dc:creator>
      <dc:date>2013-01-10T01:01:42Z</dc:date>
    </item>
  </channel>
</rss>

