View Single Post
05/29/23, 07:10 PM   #8
Sharlikran
 
Sharlikran's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 659
Also go to an online Lua compiler

Code:
local value = "10,000"
print(tonumber(value))
That will return nil

Code:
local value = "10,000"
value = string.gsub(value, ",", "")
print(tonumber(value))
That will return 10000

Code:
local value = "10,000"
value = value:gsub(",", "")
print(tonumber(value))
Even that if you want

Also you probably want to use Regex because that will only work for English with a comma. It won't work for any foreign number with a period for the separator.

Code:
local value = "10.000"
value = value:gsub("[%p%c%s]", "")
print(tonumber(value))

Last edited by Sharlikran : 05/29/23 at 07:16 PM.
  Reply With Quote