Thread: IsNumeric
View Single Post
11-14-13, 08:36 AM   #3
Billtopia
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Apr 2009
Posts: 110
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
  Reply With Quote