Thread: IsNumeric
View Single Post
11-14-13, 08:56 AM   #5
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Billtopia View Post
I was thinking that this may be better for you but not 100% the pattern is right. It should find any decimal number including decimals with a decimal portion and if that is the only thing on the line (not counting white spaces) then return true

lua Code:
  1. function IsNumeric( data )
  2.     if type(data) == "number" then
  3.         return true
  4.     elseif type(data) ~= "string" then
  5.         return false
  6.     end
  7.     data = strtrim(data)
  8.     local x, y = string.find(data, "[%d+][%.?][%d*]")
  9.     if x and x == 1 and y == strlen(data) then
  10.         return true
  11.     end
  12.     return false
  13. end
Hmm thats seems good, but i think it's slower then my method.
  Reply With Quote