跳转到内容

模組:StripToNumbers

被永久保护的模块
维基百科,自由的百科全书
local p = {}
function p.main(frame)
	local theString = mw.text.unstrip(frame.args[1])
	local onlyNumber
	onlyNumber = (string.match(theString, "%-?[%d%.]+"))
	checkedNumber = tonumber(onlyNumber)
	if checkedNumber == nil then
		error(" 輸入不包含有效的數值資料數據")
	else
		return checkedNumber
	end
end

function p.halve(frame)
	local checkedNumber = (p.main(frame))
	local halvedNumber
	halvedNumber = (checkedNumber / 2)
	return halvedNumber
end
function p.mainnull(frame)
	local theString = mw.text.unstrip(frame.args[1])
	local onlyNumber
	onlyNumber = (string.match(theString, "%-?[%d%.]+"))
	checkedNumber = tonumber(onlyNumber)
	if checkedNumber == nil then
		return nil
	else
		return checkedNumber
	end
end
return p