You can edit almost every page by Creating an account and confirming your email.

Module:Sandbox/BrandonXLF/4

From EverybodyWiki Bios & Wiki

Documentation for this module may be created at Module:Sandbox/BrandonXLF/4/doc

local p = {}
function p.to (frame)
	local text = frame.args[1] or ''
	local calc;
	local groups = {
		thousand = 3,
		million = 6,
		billion = 9,
		trillion = 12
	}
	text = string.lower(text)
	text = string.gsub(text,'%W','')
	text = string.gsub(text, '(%d+)hundred', function(num)
		return tostring(tonumber(num)*100)
	end)
	for name,zeros in pairs(groups) do
		for num in string.gmatch(text,'(%d+)'..name) do
			calc = (calc or 0) + (math.pow(10,zeros) * num) 
		end
	end
	return tostring(calc)
end
return p