Jump to content

Module:Strip to numbers

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by SMcCandlish (talk | contribs) at 08:16, 18 July 2015 (code cleanup (I hope)). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local p = {}
function p.main(frame)
	local theString = frame.args[1]
	local onlyNumber
	onlyNumber = (string.gsub(theString, "[^%d%.-]", ""))
	checkedNumber = tonumber(onlyNumber)
	if checkedNumber == nil then
		error(" Input did not contain valid numeric data")
	else
		return checkedNumber
	end
end

function p.halve(frame)
	local checkedNumber = (p.main(frame))
	local halvedNumber
	halvedNumber = (checkedNumber / 2)
	return halvedNumber
end
return p