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 Mr. Stradivarius (talk | contribs) at 03:51, 19 July 2015 (extract text from nowiki tags). 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 = mw.text.unstripNoWiki(frame.args[1])
	local onlyNumber
	onlyNumber = (string.match(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